static int mp_decode_frame(AVCodecContext *avctx,

                                 void *data, int *data_size,

                                 AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    MotionPixelsContext *mp = avctx->priv_data;

    GetBitContext gb;

    int i, count1, count2, sz;



    mp->frame.reference = 1;

    mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;

    if (avctx->reget_buffer(avctx, &mp->frame)) {

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

        return -1;

    }



    /* le32 bitstream msb first */

    av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!mp->bswapbuf)

        return AVERROR(ENOMEM);

    mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)buf, buf_size / 4);

    if (buf_size & 3)

        memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3);

    init_get_bits(&gb, mp->bswapbuf, buf_size * 8);



    memset(mp->changes_map, 0, avctx->width * avctx->height);

    for (i = !(avctx->extradata[1] & 2); i < 2; ++i) {

        count1 = get_bits(&gb, 12);

        count2 = get_bits(&gb, 12);

        mp_read_changes_map(mp, &gb, count1, 8, i);

        mp_read_changes_map(mp, &gb, count2, 4, i);

    }



    mp->codes_count = get_bits(&gb, 4);

    if (mp->codes_count == 0)

        goto end;



    if (mp->changes_map[0] == 0) {

        *(uint16_t *)mp->frame.data[0] = get_bits(&gb, 15);

        mp->changes_map[0] = 1;

    }

    mp_read_codes_table(mp, &gb);



    sz = get_bits(&gb, 18);

    if (avctx->extradata[0] != 5)

        sz += get_bits(&gb, 18);

    if (sz == 0)

        goto end;



    init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);

    mp_decode_frame_helper(mp, &gb);

    free_vlc(&mp->vlc);



end:

    *data_size = sizeof(AVFrame);

    *(AVFrame *)data = mp->frame;

    return buf_size;

}

static int mp_decode_frame(AVCodecContext *avctx,

                                 void *data, int *data_size,

                                 AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    MotionPixelsContext *mp = avctx->priv_data;

    GetBitContext gb;

    int i, count1, count2, sz;



    mp->frame.reference = 1;

    mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;

    if (avctx->reget_buffer(avctx, &mp->frame)) {

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

        return -1;

    }



    

    av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!mp->bswapbuf)

        return AVERROR(ENOMEM);

    mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)buf, buf_size / 4);

    if (buf_size & 3)

        memcpy(mp->bswapbuf + (buf_size & ~3), buf + (buf_size & ~3), buf_size & 3);

    init_get_bits(&gb, mp->bswapbuf, buf_size * 8);



    memset(mp->changes_map, 0, avctx->width * avctx->height);

    for (i = !(avctx->extradata[1] & 2); i < 2; ++i) {

        count1 = get_bits(&gb, 12);

        count2 = get_bits(&gb, 12);

        mp_read_changes_map(mp, &gb, count1, 8, i);

        mp_read_changes_map(mp, &gb, count2, 4, i);

    }



    mp->codes_count = get_bits(&gb, 4);

    if (mp->codes_count == 0)

        goto end;



    if (mp->changes_map[0] == 0) {

        *(uint16_t *)mp->frame.data[0] = get_bits(&gb, 15);

        mp->changes_map[0] = 1;

    }

    mp_read_codes_table(mp, &gb);



    sz = get_bits(&gb, 18);

    if (avctx->extradata[0] != 5)

        sz += get_bits(&gb, 18);

    if (sz == 0)

        goto end;



    init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);

    mp_decode_frame_helper(mp, &gb);

    free_vlc(&mp->vlc);



end:

    *data_size = sizeof(AVFrame);

    *(AVFrame *)data = mp->frame;

    return buf_size;

}

    init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);
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;

    MotionPixelsContext *mp = VAR_0->priv_data;

    GetBitContext gb;

    int VAR_6, VAR_7, VAR_8, VAR_9;



    mp->frame.reference = 1;

    mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;

    if (VAR_0->reget_buffer(VAR_0, &mp->frame)) {

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

        return -1;

    }



    

    av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!mp->bswapbuf)

        return AVERROR(ENOMEM);

    mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)VAR_4, VAR_5 / 4);

    if (VAR_5 & 3)

        memcpy(mp->bswapbuf + (VAR_5 & ~3), VAR_4 + (VAR_5 & ~3), VAR_5 & 3);

    init_get_bits(&gb, mp->bswapbuf, VAR_5 * 8);



    memset(mp->changes_map, 0, VAR_0->width * VAR_0->height);

    for (VAR_6 = !(VAR_0->extradata[1] & 2); VAR_6 < 2; ++VAR_6) {

        VAR_7 = get_bits(&gb, 12);

        VAR_8 = get_bits(&gb, 12);

        mp_read_changes_map(mp, &gb, VAR_7, 8, VAR_6);

        mp_read_changes_map(mp, &gb, VAR_8, 4, VAR_6);

    }



    mp->codes_count = get_bits(&gb, 4);

    if (mp->codes_count == 0)

        goto end;



    if (mp->changes_map[0] == 0) {

        *(uint16_t *)mp->frame.VAR_1[0] = get_bits(&gb, 15);

        mp->changes_map[0] = 1;

    }

    mp_read_codes_table(mp, &gb);



    VAR_9 = get_bits(&gb, 18);

    if (VAR_0->extradata[0] != 5)

        VAR_9 += get_bits(&gb, 18);

    if (VAR_9 == 0)

        goto end;



    init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0);

    mp_decode_frame_helper(mp, &gb);

    free_vlc(&mp->vlc);



end:

    *VAR_2 = sizeof(AVFrame);

    *(AVFrame *)VAR_1 = mp->frame;

    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; MotionPixelsContext *mp = VAR_0->priv_data; GetBitContext gb; int VAR_6, VAR_7, VAR_8, VAR_9; mp->frame.reference = 1; mp->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (VAR_0->reget_buffer(VAR_0, &mp->frame)) { av_log(VAR_0, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; } av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, VAR_5 + FF_INPUT_BUFFER_PADDING_SIZE); if (!mp->bswapbuf)
return AVERROR(ENOMEM); mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)VAR_4, VAR_5 / 4); if (VAR_5 & 3)
memcpy(mp->bswapbuf + (VAR_5 & ~3), VAR_4 + (VAR_5 & ~3), VAR_5 & 3); init_get_bits(&gb, mp->bswapbuf, VAR_5 * 8); memset(mp->changes_map, 0, VAR_0->width * VAR_0->height); for (VAR_6 = !(VAR_0->extradata[1] & 2); VAR_6 < 2; ++VAR_6) { VAR_7 = get_bits(&gb, 12); VAR_8 = get_bits(&gb, 12); mp_read_changes_map(mp, &gb, VAR_7, 8, VAR_6); mp_read_changes_map(mp, &gb, VAR_8, 4, VAR_6); } mp->codes_count = get_bits(&gb, 4); if (mp->codes_count == 0)
goto end; if (mp->changes_map[0] == 0) { *(uint16_t *)mp->frame.VAR_1[0] = get_bits(&gb, 15); mp->changes_map[0] = 1; } mp_read_codes_table(mp, &gb); VAR_9 = get_bits(&gb, 18); if (VAR_0->extradata[0] != 5)
VAR_9 += get_bits(&gb, 18); if (VAR_9 == 0)
goto end; init_vlc(&mp->vlc, mp->max_codes_bits, mp->codes_count, &mp->codes[0].size, sizeof(HuffCode), 1, &mp->codes[0].code, sizeof(HuffCode), 4, 0); mp_decode_frame_helper(mp, &gb); free_vlc(&mp->vlc); end:
*VAR_2 = sizeof(AVFrame); *(AVFrame *)VAR_1 = mp->frame; return VAR_5; }