static void write_header(FFV1Context *f)

{

    uint8_t state[CONTEXT_SIZE];

    int i, j;

    RangeCoder *const c = &f->slice_context[0]->c;



    memset(state, 128, sizeof(state));



    if (f->version < 2) {

        put_symbol(c, state, f->version, 0);

        put_symbol(c, state, f->ac, 0);

        if (f->ac > 1) {

            for (i = 1; i < 256; i++)

                put_symbol(c, state,

                           f->state_transition[i] - c->one_state[i], 1);

        }

        put_symbol(c, state, f->colorspace, 0); // YUV cs type

        if (f->version > 0)

            put_symbol(c, state, f->bits_per_raw_sample, 0);

        put_rac(c, state, f->chroma_planes);

        put_symbol(c, state, f->chroma_h_shift, 0);

        put_symbol(c, state, f->chroma_v_shift, 0);

        put_rac(c, state, f->transparency);



        write_quant_tables(c, f->quant_table);

    } else if (f->version < 3) {

        put_symbol(c, state, f->slice_count, 0);

        for (i = 0; i < f->slice_count; i++) {

            FFV1Context *fs = f->slice_context[i];

            put_symbol(c, state,

                       (fs->slice_x      + 1) * f->num_h_slices / f->width, 0);

            put_symbol(c, state,

                       (fs->slice_y      + 1) * f->num_v_slices / f->height, 0);

            put_symbol(c, state,

                       (fs->slice_width  + 1) * f->num_h_slices / f->width - 1,

                       0);

            put_symbol(c, state,

                       (fs->slice_height + 1) * f->num_v_slices / f->height - 1,

                       0);

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

                put_symbol(c, state, f->plane[j].quant_table_index, 0);

                av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);

            }

        }

    }

}

static void write_header(FFV1Context *f)

{

    uint8_t state[CONTEXT_SIZE];

    int i, j;

    RangeCoder *const c = &f->slice_context[0]->c;



    memset(state, 128, sizeof(state));



    if (f->version < 2) {

        put_symbol(c, state, f->version, 0);

        put_symbol(c, state, f->ac, 0);

        if (f->ac > 1) {

            for (i = 1; i < 256; i++)

                put_symbol(c, state,

                           f->state_transition[i] - c->one_state[i], 1);

        }

        put_symbol(c, state, f->colorspace, 0); 

        if (f->version > 0)

            put_symbol(c, state, f->bits_per_raw_sample, 0);

        put_rac(c, state, f->chroma_planes);

        put_symbol(c, state, f->chroma_h_shift, 0);

        put_symbol(c, state, f->chroma_v_shift, 0);

        put_rac(c, state, f->transparency);



        write_quant_tables(c, f->quant_table);

    } else if (f->version < 3) {

        put_symbol(c, state, f->slice_count, 0);

        for (i = 0; i < f->slice_count; i++) {

            FFV1Context *fs = f->slice_context[i];

            put_symbol(c, state,

                       (fs->slice_x      + 1) * f->num_h_slices / f->width, 0);

            put_symbol(c, state,

                       (fs->slice_y      + 1) * f->num_v_slices / f->height, 0);

            put_symbol(c, state,

                       (fs->slice_width  + 1) * f->num_h_slices / f->width - 1,

                       0);

            put_symbol(c, state,

                       (fs->slice_height + 1) * f->num_v_slices / f->height - 1,

                       0);

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

                put_symbol(c, state, f->plane[j].quant_table_index, 0);

                av_assert0(f->plane[j].quant_table_index == f->avctx->context_model);

            }

        }

    }

}

static void FUNC_0(FFV1Context *VAR_0)

{

    uint8_t state[CONTEXT_SIZE];

    int VAR_1, VAR_2;

    RangeCoder *const c = &VAR_0->slice_context[0]->c;



    memset(state, 128, sizeof(state));



    if (VAR_0->version < 2) {

        put_symbol(c, state, VAR_0->version, 0);

        put_symbol(c, state, VAR_0->ac, 0);

        if (VAR_0->ac > 1) {

            for (VAR_1 = 1; VAR_1 < 256; VAR_1++)

                put_symbol(c, state,

                           VAR_0->state_transition[VAR_1] - c->one_state[VAR_1], 1);

        }

        put_symbol(c, state, VAR_0->colorspace, 0); 

        if (VAR_0->version > 0)

            put_symbol(c, state, VAR_0->bits_per_raw_sample, 0);

        put_rac(c, state, VAR_0->chroma_planes);

        put_symbol(c, state, VAR_0->chroma_h_shift, 0);

        put_symbol(c, state, VAR_0->chroma_v_shift, 0);

        put_rac(c, state, VAR_0->transparency);



        write_quant_tables(c, VAR_0->quant_table);

    } else if (VAR_0->version < 3) {

        put_symbol(c, state, VAR_0->slice_count, 0);

        for (VAR_1 = 0; VAR_1 < VAR_0->slice_count; VAR_1++) {

            FFV1Context *fs = VAR_0->slice_context[VAR_1];

            put_symbol(c, state,

                       (fs->slice_x      + 1) * VAR_0->num_h_slices / VAR_0->width, 0);

            put_symbol(c, state,

                       (fs->slice_y      + 1) * VAR_0->num_v_slices / VAR_0->height, 0);

            put_symbol(c, state,

                       (fs->slice_width  + 1) * VAR_0->num_h_slices / VAR_0->width - 1,

                       0);

            put_symbol(c, state,

                       (fs->slice_height + 1) * VAR_0->num_v_slices / VAR_0->height - 1,

                       0);

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

                put_symbol(c, state, VAR_0->plane[VAR_2].quant_table_index, 0);

                av_assert0(VAR_0->plane[VAR_2].quant_table_index == VAR_0->avctx->context_model);

            }

        }

    }

}

static void FUNC_0(FFV1Context *VAR_0)
{ uint8_t state[CONTEXT_SIZE]; int VAR_1, VAR_2; RangeCoder *const c = &VAR_0->slice_context[0]->c; memset(state, 128, sizeof(state)); if (VAR_0->version < 2) { put_symbol(c, state, VAR_0->version, 0); put_symbol(c, state, VAR_0->ac, 0); if (VAR_0->ac > 1) { for (VAR_1 = 1; VAR_1 < 256; VAR_1++) put_symbol(c, state,
VAR_0->state_transition[VAR_1] - c->one_state[VAR_1], 1); } put_symbol(c, state, VAR_0->colorspace, 0); if (VAR_0->version > 0)
put_symbol(c, state, VAR_0->bits_per_raw_sample, 0); put_rac(c, state, VAR_0->chroma_planes); put_symbol(c, state, VAR_0->chroma_h_shift, 0); put_symbol(c, state, VAR_0->chroma_v_shift, 0); put_rac(c, state, VAR_0->transparency); write_quant_tables(c, VAR_0->quant_table); } else if (VAR_0->version < 3) { put_symbol(c, state, VAR_0->slice_count, 0); for (VAR_1 = 0; VAR_1 < VAR_0->slice_count; VAR_1++) { FFV1Context *fs = VAR_0->slice_context[VAR_1]; put_symbol(c, state,
(fs->slice_x      + 1) * VAR_0->num_h_slices / VAR_0->width, 0); put_symbol(c, state,
(fs->slice_y      + 1) * VAR_0->num_v_slices / VAR_0->height, 0); put_symbol(c, state,
(fs->slice_width  + 1) * VAR_0->num_h_slices / VAR_0->width - 1,
0); put_symbol(c, state,
(fs->slice_height + 1) * VAR_0->num_v_slices / VAR_0->height - 1,
0); for (VAR_2 = 0; VAR_2 < VAR_0->plane_count; VAR_2++) { put_symbol(c, state, VAR_0->plane[VAR_2].quant_table_index, 0); av_assert0(VAR_0->plane[VAR_2].quant_table_index == VAR_0->avctx->context_model); } } } }