static int vorbis_floor1_decode(vorbis_context *vc,

                                vorbis_floor_data *vfu, float *vec)

{

    vorbis_floor1 *vf = &vfu->t1;

    GetBitContext *gb = &vc->gb;

    uint16_t range_v[4] = { 256, 128, 86, 64 };

    unsigned range = range_v[vf->multiplier - 1];

    uint16_t floor1_Y[258];

    uint16_t floor1_Y_final[258];

    int floor1_flag[258];

    unsigned partition_class, cdim, cbits, csub, cval, offset, i, j;

    int book, adx, ady, dy, off, predicted, err;





    if (!get_bits1(gb)) // silence

        return 1;



// Read values (or differences) for the floor's points



    floor1_Y[0] = get_bits(gb, ilog(range - 1));

    floor1_Y[1] = get_bits(gb, ilog(range - 1));



    av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);



    offset = 2;

    for (i = 0; i < vf->partitions; ++i) {

        partition_class = vf->partition_class[i];

        cdim   = vf->class_dimensions[partition_class];

        cbits  = vf->class_subclasses[partition_class];

        csub = (1 << cbits) - 1;

        cval = 0;



        av_dlog(NULL, "Cbits %u\n", cbits);



        if (cbits) // this reads all subclasses for this partition's class

            cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[partition_class]].vlc.table,

                            vc->codebooks[vf->class_masterbook[partition_class]].nb_bits, 3);



        for (j = 0; j < cdim; ++j) {

            book = vf->subclass_books[partition_class][cval & csub];



            av_dlog(NULL, "book %d Cbits %u cval %u  bits:%d\n",

                    book, cbits, cval, get_bits_count(gb));



            cval = cval >> cbits;

            if (book > -1) {

                floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,

                vc->codebooks[book].nb_bits, 3);

            } else {

                floor1_Y[offset+j] = 0;

            }



            av_dlog(NULL, " floor(%d) = %d \n",

                    vf->list[offset+j].x, floor1_Y[offset+j]);

        }

        offset+=cdim;

    }



// Amplitude calculation from the differences



    floor1_flag[0] = 1;

    floor1_flag[1] = 1;

    floor1_Y_final[0] = floor1_Y[0];

    floor1_Y_final[1] = floor1_Y[1];



    for (i = 2; i < vf->x_list_dim; ++i) {

        unsigned val, highroom, lowroom, room, high_neigh_offs, low_neigh_offs;



        low_neigh_offs  = vf->list[i].low;

        high_neigh_offs = vf->list[i].high;

        dy  = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs];  // render_point begin

        adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;

        ady = FFABS(dy);

        err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);

        off = err / adx;

        if (dy < 0) {

            predicted = floor1_Y_final[low_neigh_offs] - off;

        } else {

            predicted = floor1_Y_final[low_neigh_offs] + off;

        } // render_point end



        val = floor1_Y[i];

        highroom = range-predicted;

        lowroom  = predicted;

        if (highroom < lowroom) {

            room = highroom * 2;

        } else {

            room = lowroom * 2;   // SPEC misspelling

        }

        if (val) {

            floor1_flag[low_neigh_offs]  = 1;

            floor1_flag[high_neigh_offs] = 1;

            floor1_flag[i]               = 1;

            if (val >= room) {

                if (highroom > lowroom) {

                    floor1_Y_final[i] = av_clip_uint16(val - lowroom + predicted);

                } else {

                    floor1_Y_final[i] = av_clip_uint16(predicted - val + highroom - 1);

                }

            } else {

                if (val & 1) {

                    floor1_Y_final[i] = av_clip_uint16(predicted - (val + 1) / 2);

                } else {

                    floor1_Y_final[i] = av_clip_uint16(predicted + val / 2);

                }

            }

        } else {

            floor1_flag[i]    = 0;

            floor1_Y_final[i] = av_clip_uint16(predicted);

        }



        av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",

                vf->list[i].x, floor1_Y_final[i], val);

    }



// Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ?



    ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);



    av_dlog(NULL, " Floor decoded\n");



    return 0;

}

static int vorbis_floor1_decode(vorbis_context *vc,

                                vorbis_floor_data *vfu, float *vec)

{

    vorbis_floor1 *vf = &vfu->t1;

    GetBitContext *gb = &vc->gb;

    uint16_t range_v[4] = { 256, 128, 86, 64 };

    unsigned range = range_v[vf->multiplier - 1];

    uint16_t floor1_Y[258];

    uint16_t floor1_Y_final[258];

    int floor1_flag[258];

    unsigned partition_class, cdim, cbits, csub, cval, offset, i, j;

    int book, adx, ady, dy, off, predicted, err;





    if (!get_bits1(gb)) 

        return 1;







    floor1_Y[0] = get_bits(gb, ilog(range - 1));

    floor1_Y[1] = get_bits(gb, ilog(range - 1));



    av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);



    offset = 2;

    for (i = 0; i < vf->partitions; ++i) {

        partition_class = vf->partition_class[i];

        cdim   = vf->class_dimensions[partition_class];

        cbits  = vf->class_subclasses[partition_class];

        csub = (1 << cbits) - 1;

        cval = 0;



        av_dlog(NULL, "Cbits %u\n", cbits);



        if (cbits) 

            cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[partition_class]].vlc.table,

                            vc->codebooks[vf->class_masterbook[partition_class]].nb_bits, 3);



        for (j = 0; j < cdim; ++j) {

            book = vf->subclass_books[partition_class][cval & csub];



            av_dlog(NULL, "book %d Cbits %u cval %u  bits:%d\n",

                    book, cbits, cval, get_bits_count(gb));



            cval = cval >> cbits;

            if (book > -1) {

                floor1_Y[offset+j] = get_vlc2(gb, vc->codebooks[book].vlc.table,

                vc->codebooks[book].nb_bits, 3);

            } else {

                floor1_Y[offset+j] = 0;

            }



            av_dlog(NULL, " floor(%d) = %d \n",

                    vf->list[offset+j].x, floor1_Y[offset+j]);

        }

        offset+=cdim;

    }







    floor1_flag[0] = 1;

    floor1_flag[1] = 1;

    floor1_Y_final[0] = floor1_Y[0];

    floor1_Y_final[1] = floor1_Y[1];



    for (i = 2; i < vf->x_list_dim; ++i) {

        unsigned val, highroom, lowroom, room, high_neigh_offs, low_neigh_offs;



        low_neigh_offs  = vf->list[i].low;

        high_neigh_offs = vf->list[i].high;

        dy  = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs];  

        adx = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;

        ady = FFABS(dy);

        err = ady * (vf->list[i].x - vf->list[low_neigh_offs].x);

        off = err / adx;

        if (dy < 0) {

            predicted = floor1_Y_final[low_neigh_offs] - off;

        } else {

            predicted = floor1_Y_final[low_neigh_offs] + off;

        } 



        val = floor1_Y[i];

        highroom = range-predicted;

        lowroom  = predicted;

        if (highroom < lowroom) {

            room = highroom * 2;

        } else {

            room = lowroom * 2;   

        }

        if (val) {

            floor1_flag[low_neigh_offs]  = 1;

            floor1_flag[high_neigh_offs] = 1;

            floor1_flag[i]               = 1;

            if (val >= room) {

                if (highroom > lowroom) {

                    floor1_Y_final[i] = av_clip_uint16(val - lowroom + predicted);

                } else {

                    floor1_Y_final[i] = av_clip_uint16(predicted - val + highroom - 1);

                }

            } else {

                if (val & 1) {

                    floor1_Y_final[i] = av_clip_uint16(predicted - (val + 1) / 2);

                } else {

                    floor1_Y_final[i] = av_clip_uint16(predicted + val / 2);

                }

            }

        } else {

            floor1_flag[i]    = 0;

            floor1_Y_final[i] = av_clip_uint16(predicted);

        }



        av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",

                vf->list[i].x, floor1_Y_final[i], val);

    }







    ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);



    av_dlog(NULL, " Floor decoded\n");



    return 0;

}

static int FUNC_0(vorbis_context *VAR_0,

                                vorbis_floor_data *VAR_1, float *VAR_2)

{

    vorbis_floor1 *vf = &VAR_1->t1;

    GetBitContext *gb = &VAR_0->gb;

    uint16_t range_v[4] = { 256, 128, 86, 64 };

    unsigned VAR_3 = range_v[vf->multiplier - 1];

    uint16_t floor1_Y[258];

    uint16_t floor1_Y_final[258];

    int VAR_4[258];

    unsigned VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;

    int VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19;





    if (!get_bits1(gb)) 

        return 1;







    floor1_Y[0] = get_bits(gb, ilog(VAR_3 - 1));

    floor1_Y[1] = get_bits(gb, ilog(VAR_3 - 1));



    av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);



    VAR_10 = 2;

    for (VAR_11 = 0; VAR_11 < vf->partitions; ++VAR_11) {

        VAR_5 = vf->VAR_5[VAR_11];

        VAR_6   = vf->class_dimensions[VAR_5];

        VAR_7  = vf->class_subclasses[VAR_5];

        VAR_8 = (1 << VAR_7) - 1;

        VAR_9 = 0;



        av_dlog(NULL, "Cbits %u\n", VAR_7);



        if (VAR_7) 

            VAR_9 = get_vlc2(gb, VAR_0->codebooks[vf->class_masterbook[VAR_5]].vlc.table,

                            VAR_0->codebooks[vf->class_masterbook[VAR_5]].nb_bits, 3);



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

            VAR_13 = vf->subclass_books[VAR_5][VAR_9 & VAR_8];



            av_dlog(NULL, "VAR_13 %d Cbits %u VAR_9 %u  bits:%d\n",

                    VAR_13, VAR_7, VAR_9, get_bits_count(gb));



            VAR_9 = VAR_9 >> VAR_7;

            if (VAR_13 > -1) {

                floor1_Y[VAR_10+VAR_12] = get_vlc2(gb, VAR_0->codebooks[VAR_13].vlc.table,

                VAR_0->codebooks[VAR_13].nb_bits, 3);

            } else {

                floor1_Y[VAR_10+VAR_12] = 0;

            }



            av_dlog(NULL, " floor(%d) = %d \n",

                    vf->list[VAR_10+VAR_12].x, floor1_Y[VAR_10+VAR_12]);

        }

        VAR_10+=VAR_6;

    }







    VAR_4[0] = 1;

    VAR_4[1] = 1;

    floor1_Y_final[0] = floor1_Y[0];

    floor1_Y_final[1] = floor1_Y[1];



    for (VAR_11 = 2; VAR_11 < vf->x_list_dim; ++VAR_11) {

        unsigned val, highroom, lowroom, room, high_neigh_offs, low_neigh_offs;



        low_neigh_offs  = vf->list[VAR_11].low;

        high_neigh_offs = vf->list[VAR_11].high;

        VAR_16  = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs];  

        VAR_14 = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x;

        VAR_15 = FFABS(VAR_16);

        VAR_19 = VAR_15 * (vf->list[VAR_11].x - vf->list[low_neigh_offs].x);

        VAR_17 = VAR_19 / VAR_14;

        if (VAR_16 < 0) {

            VAR_18 = floor1_Y_final[low_neigh_offs] - VAR_17;

        } else {

            VAR_18 = floor1_Y_final[low_neigh_offs] + VAR_17;

        } 



        val = floor1_Y[VAR_11];

        highroom = VAR_3-VAR_18;

        lowroom  = VAR_18;

        if (highroom < lowroom) {

            room = highroom * 2;

        } else {

            room = lowroom * 2;   

        }

        if (val) {

            VAR_4[low_neigh_offs]  = 1;

            VAR_4[high_neigh_offs] = 1;

            VAR_4[VAR_11]               = 1;

            if (val >= room) {

                if (highroom > lowroom) {

                    floor1_Y_final[VAR_11] = av_clip_uint16(val - lowroom + VAR_18);

                } else {

                    floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18 - val + highroom - 1);

                }

            } else {

                if (val & 1) {

                    floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18 - (val + 1) / 2);

                } else {

                    floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18 + val / 2);

                }

            }

        } else {

            VAR_4[VAR_11]    = 0;

            floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18);

        }



        av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",

                vf->list[VAR_11].x, floor1_Y_final[VAR_11], val);

    }







    ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, VAR_4, vf->multiplier, VAR_2, vf->list[1].x);



    av_dlog(NULL, " Floor decoded\n");



    return 0;

}

static int FUNC_0(vorbis_context *VAR_0,
vorbis_floor_data *VAR_1, float *VAR_2)
{ vorbis_floor1 *vf = &VAR_1->t1; GetBitContext *gb = &VAR_0->gb; uint16_t range_v[4] = { 256, 128, 86, 64 }; unsigned VAR_3 = range_v[vf->multiplier - 1]; uint16_t floor1_Y[258]; uint16_t floor1_Y_final[258]; int VAR_4[258]; unsigned VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; int VAR_13, VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19; if (!get_bits1(gb))
return 1; floor1_Y[0] = get_bits(gb, ilog(VAR_3 - 1)); floor1_Y[1] = get_bits(gb, ilog(VAR_3 - 1)); av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]); VAR_10 = 2; for (VAR_11 = 0; VAR_11 < vf->partitions; ++VAR_11) { VAR_5 = vf->VAR_5[VAR_11]; VAR_6   = vf->class_dimensions[VAR_5]; VAR_7  = vf->class_subclasses[VAR_5]; VAR_8 = (1 << VAR_7) - 1; VAR_9 = 0; av_dlog(NULL, "Cbits %u\n", VAR_7); if (VAR_7)
VAR_9 = get_vlc2(gb, VAR_0->codebooks[vf->class_masterbook[VAR_5]].vlc.table,
VAR_0->codebooks[vf->class_masterbook[VAR_5]].nb_bits, 3); for (VAR_12 = 0; VAR_12 < VAR_6; ++VAR_12) { VAR_13 = vf->subclass_books[VAR_5][VAR_9 & VAR_8]; av_dlog(NULL, "VAR_13 %d Cbits %u VAR_9 %u  bits:%d\n",
VAR_13, VAR_7, VAR_9, get_bits_count(gb)); VAR_9 = VAR_9 >> VAR_7; if (VAR_13 > -1) { floor1_Y[VAR_10+VAR_12] = get_vlc2(gb, VAR_0->codebooks[VAR_13].vlc.table,
VAR_0->codebooks[VAR_13].nb_bits, 3); } else { floor1_Y[VAR_10+VAR_12] = 0; } av_dlog(NULL, " floor(%d) = %d \n",
vf->list[VAR_10+VAR_12].x, floor1_Y[VAR_10+VAR_12]); } VAR_10+=VAR_6; } VAR_4[0] = 1; VAR_4[1] = 1; floor1_Y_final[0] = floor1_Y[0]; floor1_Y_final[1] = floor1_Y[1]; for (VAR_11 = 2; VAR_11 < vf->x_list_dim; ++VAR_11) { unsigned val, highroom, lowroom, room, high_neigh_offs, low_neigh_offs; low_neigh_offs  = vf->list[VAR_11].low; high_neigh_offs = vf->list[VAR_11].high; VAR_16  = floor1_Y_final[high_neigh_offs] - floor1_Y_final[low_neigh_offs]; VAR_14 = vf->list[high_neigh_offs].x - vf->list[low_neigh_offs].x; VAR_15 = FFABS(VAR_16); VAR_19 = VAR_15 * (vf->list[VAR_11].x - vf->list[low_neigh_offs].x); VAR_17 = VAR_19 / VAR_14; if (VAR_16 < 0) { VAR_18 = floor1_Y_final[low_neigh_offs] - VAR_17; } else { VAR_18 = floor1_Y_final[low_neigh_offs] + VAR_17; } val = floor1_Y[VAR_11]; highroom = VAR_3-VAR_18; lowroom  = VAR_18; if (highroom < lowroom) { room = highroom * 2; } else { room = lowroom * 2; } if (val) { VAR_4[low_neigh_offs]  = 1; VAR_4[high_neigh_offs] = 1; VAR_4[VAR_11]               = 1; if (val >= room) { if (highroom > lowroom) { floor1_Y_final[VAR_11] = av_clip_uint16(val - lowroom + VAR_18); } else { floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18 - val + highroom - 1); } } else { if (val & 1) { floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18 - (val + 1) / 2); } else { floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18 + val / 2); } } } else { VAR_4[VAR_11]    = 0; floor1_Y_final[VAR_11] = av_clip_uint16(VAR_18); } av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",
vf->list[VAR_11].x, floor1_Y_final[VAR_11], val); } ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, VAR_4, vf->multiplier, VAR_2, vf->list[1].x); av_dlog(NULL, " Floor decoded\n"); return 0; }