static double fade_gain(int curve, int64_t index, int range)

{

    double gain;



    gain = av_clipd(1.0 * index / range, 0, 1.0);



    switch (curve) {

    case QSIN:

        gain = sin(gain * M_PI / 2.0);

        break;

    case IQSIN:

        gain = 0.636943 * asin(gain);

        break;

    case ESIN:

        gain = 1.0 - cos(M_PI / 4.0 * (pow(2.0*gain - 1, 3) + 1));

        break;

    case HSIN:

        gain = (1.0 - cos(gain * M_PI)) / 2.0;

        break;

    case IHSIN:

        gain = 0.318471 * acos(1 - 2 * gain);

        break;

    case EXP:

        gain = pow(0.1, (1 - gain) * 5.0);

        break;

    case LOG:

        gain = av_clipd(0.0868589 * log(100000 * gain), 0, 1.0);

        break;

    case PAR:

        gain = 1 - sqrt(1 - gain);

        break;

    case IPAR:

        gain = (1 - (1 - gain) * (1 - gain));

        break;

    case QUA:

        gain *= gain;

        break;

    case CUB:

        gain = gain * gain * gain;

        break;

    case SQU:

        gain = sqrt(gain);

        break;

    case CBR:

        gain = cbrt(gain);

        break;

    case DESE:

        gain = gain <= 0.5 ? pow(2 * gain, 1/3.) / 2: 1 - pow(2 * (1 - gain), 1/3.) / 2;

        break;

    case DESI:

        gain = gain <= 0.5 ? pow(2 * gain, 3) / 2: 1 - pow(2 * (1 - gain), 3) / 2;

        break;

    }



    return gain;

}

static double fade_gain(int curve, int64_t index, int range)

{

    double gain;



    gain = av_clipd(1.0 * index / range, 0, 1.0);



    switch (curve) {

    case QSIN:

        gain = sin(gain * M_PI / 2.0);

        break;

    case IQSIN:

        gain = 0.636943 * asin(gain);

        break;

    case ESIN:

        gain = 1.0 - cos(M_PI / 4.0 * (pow(2.0*gain - 1, 3) + 1));

        break;

    case HSIN:

        gain = (1.0 - cos(gain * M_PI)) / 2.0;

        break;

    case IHSIN:

        gain = 0.318471 * acos(1 - 2 * gain);

        break;

    case EXP:

        gain = pow(0.1, (1 - gain) * 5.0);

        break;

    case LOG:

        gain = av_clipd(0.0868589 * log(100000 * gain), 0, 1.0);

        break;

    case PAR:

        gain = 1 - sqrt(1 - gain);

        break;

    case IPAR:

        gain = (1 - (1 - gain) * (1 - gain));

        break;

    case QUA:

        gain *= gain;

        break;

    case CUB:

        gain = gain * gain * gain;

        break;

    case SQU:

        gain = sqrt(gain);

        break;

    case CBR:

        gain = cbrt(gain);

        break;

    case DESE:

        gain = gain <= 0.5 ? pow(2 * gain, 1/3.) / 2: 1 - pow(2 * (1 - gain), 1/3.) / 2;

        break;

    case DESI:

        gain = gain <= 0.5 ? pow(2 * gain, 3) / 2: 1 - pow(2 * (1 - gain), 3) / 2;

        break;

    }



    return gain;

}

static double FUNC_0(int VAR_0, int64_t VAR_1, int VAR_2)

{

    double VAR_3;



    VAR_3 = av_clipd(1.0 * VAR_1 / VAR_2, 0, 1.0);



    switch (VAR_0) {

    case QSIN:

        VAR_3 = sin(VAR_3 * M_PI / 2.0);

        break;

    case IQSIN:

        VAR_3 = 0.636943 * asin(VAR_3);

        break;

    case ESIN:

        VAR_3 = 1.0 - cos(M_PI / 4.0 * (pow(2.0*VAR_3 - 1, 3) + 1));

        break;

    case HSIN:

        VAR_3 = (1.0 - cos(VAR_3 * M_PI)) / 2.0;

        break;

    case IHSIN:

        VAR_3 = 0.318471 * acos(1 - 2 * VAR_3);

        break;

    case EXP:

        VAR_3 = pow(0.1, (1 - VAR_3) * 5.0);

        break;

    case LOG:

        VAR_3 = av_clipd(0.0868589 * log(100000 * VAR_3), 0, 1.0);

        break;

    case PAR:

        VAR_3 = 1 - sqrt(1 - VAR_3);

        break;

    case IPAR:

        VAR_3 = (1 - (1 - VAR_3) * (1 - VAR_3));

        break;

    case QUA:

        VAR_3 *= VAR_3;

        break;

    case CUB:

        VAR_3 = VAR_3 * VAR_3 * VAR_3;

        break;

    case SQU:

        VAR_3 = sqrt(VAR_3);

        break;

    case CBR:

        VAR_3 = cbrt(VAR_3);

        break;

    case DESE:

        VAR_3 = VAR_3 <= 0.5 ? pow(2 * VAR_3, 1/3.) / 2: 1 - pow(2 * (1 - VAR_3), 1/3.) / 2;

        break;

    case DESI:

        VAR_3 = VAR_3 <= 0.5 ? pow(2 * VAR_3, 3) / 2: 1 - pow(2 * (1 - VAR_3), 3) / 2;

        break;

    }



    return VAR_3;

}

static double FUNC_0(int VAR_0, int64_t VAR_1, int VAR_2)
{ double VAR_3; VAR_3 = av_clipd(1.0 * VAR_1 / VAR_2, 0, 1.0); switch (VAR_0) { case QSIN:
VAR_3 = sin(VAR_3 * M_PI / 2.0); break; case IQSIN:
VAR_3 = 0.636943 * asin(VAR_3); break; case ESIN:
VAR_3 = 1.0 - cos(M_PI / 4.0 * (pow(2.0*VAR_3 - 1, 3) + 1)); break; case HSIN:
VAR_3 = (1.0 - cos(VAR_3 * M_PI)) / 2.0; break; case IHSIN:
VAR_3 = 0.318471 * acos(1 - 2 * VAR_3); break; case EXP:
VAR_3 = pow(0.1, (1 - VAR_3) * 5.0); break; case LOG:
VAR_3 = av_clipd(0.0868589 * log(100000 * VAR_3), 0, 1.0); break; case PAR:
VAR_3 = 1 - sqrt(1 - VAR_3); break; case IPAR:
VAR_3 = (1 - (1 - VAR_3) * (1 - VAR_3)); break; case QUA:
VAR_3 *= VAR_3; break; case CUB:
VAR_3 = VAR_3 * VAR_3 * VAR_3; break; case SQU:
VAR_3 = sqrt(VAR_3); break; case CBR:
VAR_3 = cbrt(VAR_3); break; case DESE:
VAR_3 = VAR_3 <= 0.5 ? pow(2 * VAR_3, 1/3.) / 2: 1 - pow(2 * (1 - VAR_3), 1/3.) / 2; break; case DESI:
VAR_3 = VAR_3 <= 0.5 ? pow(2 * VAR_3, 3) / 2: 1 - pow(2 * (1 - VAR_3), 3) / 2; break; } return VAR_3; }