static int update_error_limit(WavpackFrameContext *ctx)

{

    int i, br[2], sl[2];



    for (i = 0; i <= ctx->stereo_in; i++) {

        if (ctx->ch[i].bitrate_acc > UINT_MAX - ctx->ch[i].bitrate_delta)

            return AVERROR_INVALIDDATA;

        ctx->ch[i].bitrate_acc += ctx->ch[i].bitrate_delta;

        br[i]                   = ctx->ch[i].bitrate_acc >> 16;

        sl[i]                   = LEVEL_DECAY(ctx->ch[i].slow_level);

    }

    if (ctx->stereo_in && ctx->hybrid_bitrate) {

        int balance = (sl[1] - sl[0] + br[1] + 1) >> 1;

        if (balance > br[0]) {

            br[1] = br[0] << 1;

            br[0] = 0;

        } else if (-balance > br[0]) {

            br[0] <<= 1;

            br[1]   = 0;

        } else {

            br[1] = br[0] + balance;

            br[0] = br[0] - balance;

        }

    }

    for (i = 0; i <= ctx->stereo_in; i++) {

        if (ctx->hybrid_bitrate) {

            if (sl[i] - br[i] > -0x100)

                ctx->ch[i].error_limit = wp_exp2(sl[i] - br[i] + 0x100);

            else

                ctx->ch[i].error_limit = 0;

        } else {

            ctx->ch[i].error_limit = wp_exp2(br[i]);

        }

    }



    return 0;

}

static int update_error_limit(WavpackFrameContext *ctx)

{

    int i, br[2], sl[2];



    for (i = 0; i <= ctx->stereo_in; i++) {

        if (ctx->ch[i].bitrate_acc > UINT_MAX - ctx->ch[i].bitrate_delta)

            return AVERROR_INVALIDDATA;

        ctx->ch[i].bitrate_acc += ctx->ch[i].bitrate_delta;

        br[i]                   = ctx->ch[i].bitrate_acc >> 16;

        sl[i]                   = LEVEL_DECAY(ctx->ch[i].slow_level);

    }

    if (ctx->stereo_in && ctx->hybrid_bitrate) {

        int balance = (sl[1] - sl[0] + br[1] + 1) >> 1;

        if (balance > br[0]) {

            br[1] = br[0] << 1;

            br[0] = 0;

        } else if (-balance > br[0]) {

            br[0] <<= 1;

            br[1]   = 0;

        } else {

            br[1] = br[0] + balance;

            br[0] = br[0] - balance;

        }

    }

    for (i = 0; i <= ctx->stereo_in; i++) {

        if (ctx->hybrid_bitrate) {

            if (sl[i] - br[i] > -0x100)

                ctx->ch[i].error_limit = wp_exp2(sl[i] - br[i] + 0x100);

            else

                ctx->ch[i].error_limit = 0;

        } else {

            ctx->ch[i].error_limit = wp_exp2(br[i]);

        }

    }



    return 0;

}

            br[1] = br[0] << 1;             br[0] <<= 1;
static int FUNC_0(WavpackFrameContext *VAR_0)

{

    int VAR_1, VAR_2[2], VAR_3[2];



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

        if (VAR_0->ch[VAR_1].bitrate_acc > UINT_MAX - VAR_0->ch[VAR_1].bitrate_delta)

            return AVERROR_INVALIDDATA;

        VAR_0->ch[VAR_1].bitrate_acc += VAR_0->ch[VAR_1].bitrate_delta;

        VAR_2[VAR_1]                   = VAR_0->ch[VAR_1].bitrate_acc >> 16;

        VAR_3[VAR_1]                   = LEVEL_DECAY(VAR_0->ch[VAR_1].slow_level);

    }

    if (VAR_0->stereo_in && VAR_0->hybrid_bitrate) {

        int VAR_4 = (VAR_3[1] - VAR_3[0] + VAR_2[1] + 1) >> 1;

        if (VAR_4 > VAR_2[0]) {

            VAR_2[1] = VAR_2[0] << 1;

            VAR_2[0] = 0;

        } else if (-VAR_4 > VAR_2[0]) {

            VAR_2[0] <<= 1;

            VAR_2[1]   = 0;

        } else {

            VAR_2[1] = VAR_2[0] + VAR_4;

            VAR_2[0] = VAR_2[0] - VAR_4;

        }

    }

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

        if (VAR_0->hybrid_bitrate) {

            if (VAR_3[VAR_1] - VAR_2[VAR_1] > -0x100)

                VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_3[VAR_1] - VAR_2[VAR_1] + 0x100);

            else

                VAR_0->ch[VAR_1].error_limit = 0;

        } else {

            VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_2[VAR_1]);

        }

    }



    return 0;

}

static int FUNC_0(WavpackFrameContext *VAR_0)
{ int VAR_1, VAR_2[2], VAR_3[2]; for (VAR_1 = 0; VAR_1 <= VAR_0->stereo_in; VAR_1++) { if (VAR_0->ch[VAR_1].bitrate_acc > UINT_MAX - VAR_0->ch[VAR_1].bitrate_delta)
return AVERROR_INVALIDDATA; VAR_0->ch[VAR_1].bitrate_acc += VAR_0->ch[VAR_1].bitrate_delta; VAR_2[VAR_1]                   = VAR_0->ch[VAR_1].bitrate_acc >> 16; VAR_3[VAR_1]                   = LEVEL_DECAY(VAR_0->ch[VAR_1].slow_level); } if (VAR_0->stereo_in && VAR_0->hybrid_bitrate) { int VAR_4 = (VAR_3[1] - VAR_3[0] + VAR_2[1] + 1) >> 1; if (VAR_4 > VAR_2[0]) { VAR_2[1] = VAR_2[0] << 1; VAR_2[0] = 0; } else if (-VAR_4 > VAR_2[0]) { VAR_2[0] <<= 1; VAR_2[1]   = 0; } else { VAR_2[1] = VAR_2[0] + VAR_4; VAR_2[0] = VAR_2[0] - VAR_4; } } for (VAR_1 = 0; VAR_1 <= VAR_0->stereo_in; VAR_1++) { if (VAR_0->hybrid_bitrate) { if (VAR_3[VAR_1] - VAR_2[VAR_1] > -0x100)
VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_3[VAR_1] - VAR_2[VAR_1] + 0x100); else
VAR_0->ch[VAR_1].error_limit = 0; } else { VAR_0->ch[VAR_1].error_limit = wp_exp2(VAR_2[VAR_1]); } } return 0; }