static int decode_frame(AVCodecContext *avctx,

                        void *data, int *data_size,

                        AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    TM2Context * const l = avctx->priv_data;

    AVFrame * const p= (AVFrame*)&l->pic;

    int i, skip, t;

    uint8_t *swbuf;



    swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);

    if(!swbuf){

        av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");

        return -1;

    }

    p->reference = 1;

    p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;

    if(avctx->reget_buffer(avctx, p) < 0){

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

        av_free(swbuf);

        return -1;

    }



    l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2);

    skip = tm2_read_header(l, swbuf);



    if(skip == -1){

        av_free(swbuf);

        return -1;

    }



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

        t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i]);

        if(t == -1){

            av_free(swbuf);

            return -1;

        }

        skip += t;

    }

    p->key_frame = tm2_decode_blocks(l, p);

    if(p->key_frame)

        p->pict_type = FF_I_TYPE;

    else

        p->pict_type = FF_P_TYPE;



    l->cur = !l->cur;

    *data_size = sizeof(AVFrame);

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

    av_free(swbuf);



    return buf_size;

}

static int decode_frame(AVCodecContext *avctx,

                        void *data, int *data_size,

                        AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    TM2Context * const l = avctx->priv_data;

    AVFrame * const p= (AVFrame*)&l->pic;

    int i, skip, t;

    uint8_t *swbuf;



    swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE);

    if(!swbuf){

        av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");

        return -1;

    }

    p->reference = 1;

    p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;

    if(avctx->reget_buffer(avctx, p) < 0){

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

        av_free(swbuf);

        return -1;

    }



    l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2);

    skip = tm2_read_header(l, swbuf);



    if(skip == -1){

        av_free(swbuf);

        return -1;

    }



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

        t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i]);

        if(t == -1){

            av_free(swbuf);

            return -1;

        }

        skip += t;

    }

    p->key_frame = tm2_decode_blocks(l, p);

    if(p->key_frame)

        p->pict_type = FF_I_TYPE;

    else

        p->pict_type = FF_P_TYPE;



    l->cur = !l->cur;

    *data_size = sizeof(AVFrame);

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

    av_free(swbuf);



    return buf_size;

}

        t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i]);
static int FUNC_0(AVCodecContext *VAR_0,

                        void *VAR_1, int *VAR_2,

                        AVPacket *VAR_3)

{

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    TM2Context * const l = VAR_0->priv_data;

    AVFrame * const p= (AVFrame*)&l->pic;

    int VAR_6, VAR_7, VAR_8;

    uint8_t *swbuf;



    swbuf = av_malloc(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);

    if(!swbuf){

        av_log(VAR_0, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");

        return -1;

    }

    p->reference = 1;

    p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;

    if(VAR_0->reget_buffer(VAR_0, p) < 0){

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

        av_free(swbuf);

        return -1;

    }



    l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)VAR_4, VAR_5 >> 2);

    VAR_7 = tm2_read_header(l, swbuf);



    if(VAR_7 == -1){

        av_free(swbuf);

        return -1;

    }



    for(VAR_6 = 0; VAR_6 < TM2_NUM_STREAMS; VAR_6++){

        VAR_8 = tm2_read_stream(l, swbuf + VAR_7, tm2_stream_order[VAR_6]);

        if(VAR_8 == -1){

            av_free(swbuf);

            return -1;

        }

        VAR_7 += VAR_8;

    }

    p->key_frame = tm2_decode_blocks(l, p);

    if(p->key_frame)

        p->pict_type = FF_I_TYPE;

    else

        p->pict_type = FF_P_TYPE;



    l->cur = !l->cur;

    *VAR_2 = sizeof(AVFrame);

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

    av_free(swbuf);



    return VAR_5;

}

static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; TM2Context * const l = VAR_0->priv_data; AVFrame * const p= (AVFrame*)&l->pic; int VAR_6, VAR_7, VAR_8; uint8_t *swbuf; swbuf = av_malloc(VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE); if(!swbuf){ av_log(VAR_0, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); return -1; } p->reference = 1; p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if(VAR_0->reget_buffer(VAR_0, p) < 0){ av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); av_free(swbuf); return -1; } l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)VAR_4, VAR_5 >> 2); VAR_7 = tm2_read_header(l, swbuf); if(VAR_7 == -1){ av_free(swbuf); return -1; } for(VAR_6 = 0; VAR_6 < TM2_NUM_STREAMS; VAR_6++){ VAR_8 = tm2_read_stream(l, swbuf + VAR_7, tm2_stream_order[VAR_6]); if(VAR_8 == -1){ av_free(swbuf); return -1; } VAR_7 += VAR_8; } p->key_frame = tm2_decode_blocks(l, p); if(p->key_frame)
p->pict_type = FF_I_TYPE; else
p->pict_type = FF_P_TYPE; l->cur = !l->cur; *VAR_2 = sizeof(AVFrame); *(AVFrame*)VAR_1 = l->pic; av_free(swbuf); return VAR_5; }