int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)

{

    int j;



    fs->plane_count  = f->plane_count;

    fs->transparency = f->transparency;

    for (j = 0; j < f->plane_count; j++) {

        PlaneContext *const p = &fs->plane[j];



        if (fs->ac) {

            if (!p->state)

                p->state = av_malloc(CONTEXT_SIZE * p->context_count *

                                     sizeof(uint8_t));

            if (!p->state)

                return AVERROR(ENOMEM);

        } else {

            if (!p->vlc_state)

                p->vlc_state = av_malloc(p->context_count * sizeof(VlcState));

            if (!p->vlc_state)

                return AVERROR(ENOMEM);

        }

    }



    if (fs->ac > 1) {

        //FIXME only redo if state_transition changed

        for (j = 1; j < 256; j++) {

            fs->c.one_state[j]        = f->state_transition[j];

            fs->c.zero_state[256 - j] = 256 - fs->c.one_state[j];

        }

    }



    return 0;

}

int ffv1_init_slice_state(FFV1Context *f, FFV1Context *fs)

{

    int j;



    fs->plane_count  = f->plane_count;

    fs->transparency = f->transparency;

    for (j = 0; j < f->plane_count; j++) {

        PlaneContext *const p = &fs->plane[j];



        if (fs->ac) {

            if (!p->state)

                p->state = av_malloc(CONTEXT_SIZE * p->context_count *

                                     sizeof(uint8_t));

            if (!p->state)

                return AVERROR(ENOMEM);

        } else {

            if (!p->vlc_state)

                p->vlc_state = av_malloc(p->context_count * sizeof(VlcState));

            if (!p->vlc_state)

                return AVERROR(ENOMEM);

        }

    }



    if (fs->ac > 1) {

        

        for (j = 1; j < 256; j++) {

            fs->c.one_state[j]        = f->state_transition[j];

            fs->c.zero_state[256 - j] = 256 - fs->c.one_state[j];

        }

    }



    return 0;

}

int FUNC_0(FFV1Context *VAR_0, FFV1Context *VAR_1)

{

    int VAR_2;



    VAR_1->plane_count  = VAR_0->plane_count;

    VAR_1->transparency = VAR_0->transparency;

    for (VAR_2 = 0; VAR_2 < VAR_0->plane_count; VAR_2++) {

        PlaneContext *const p = &VAR_1->plane[VAR_2];



        if (VAR_1->ac) {

            if (!p->state)

                p->state = av_malloc(CONTEXT_SIZE * p->context_count *

                                     sizeof(uint8_t));

            if (!p->state)

                return AVERROR(ENOMEM);

        } else {

            if (!p->vlc_state)

                p->vlc_state = av_malloc(p->context_count * sizeof(VlcState));

            if (!p->vlc_state)

                return AVERROR(ENOMEM);

        }

    }



    if (VAR_1->ac > 1) {

        

        for (VAR_2 = 1; VAR_2 < 256; VAR_2++) {

            VAR_1->c.one_state[VAR_2]        = VAR_0->state_transition[VAR_2];

            VAR_1->c.zero_state[256 - VAR_2] = 256 - VAR_1->c.one_state[VAR_2];

        }

    }



    return 0;

}

int FUNC_0(FFV1Context *VAR_0, FFV1Context *VAR_1)
{ int VAR_2; VAR_1->plane_count  = VAR_0->plane_count; VAR_1->transparency = VAR_0->transparency; for (VAR_2 = 0; VAR_2 < VAR_0->plane_count; VAR_2++) { PlaneContext *const p = &VAR_1->plane[VAR_2]; if (VAR_1->ac) { if (!p->state)
p->state = av_malloc(CONTEXT_SIZE * p->context_count *
sizeof(uint8_t)); if (!p->state)
return AVERROR(ENOMEM); } else { if (!p->vlc_state)
p->vlc_state = av_malloc(p->context_count * sizeof(VlcState)); if (!p->vlc_state)
return AVERROR(ENOMEM); } } if (VAR_1->ac > 1) { for (VAR_2 = 1; VAR_2 < 256; VAR_2++) { VAR_1->c.one_state[VAR_2]        = VAR_0->state_transition[VAR_2]; VAR_1->c.zero_state[256 - VAR_2] = 256 - VAR_1->c.one_state[VAR_2]; } } return 0; }