av_log(AV_LOG_DEBUG, "\n");
av_log(NULL, AV_LOG_DEBUG, "\n");
static int encode_exp(uint8_t encoded_exp[N/2],                       uint8_t exp[N/2],                       int nb_exps,                      int exp_strategy){    int group_size, nb_groups, i, j, k, recurse, exp_min, delta;    uint8_t exp1[N/2];    switch(exp_strategy) {    case EXP_D15:        group_size = 1;        break;    case EXP_D25:        group_size = 2;        break;    default:    case EXP_D45:        group_size = 4;        break;    }    nb_groups = ((nb_exps + (group_size * 3) - 4) / (3 * group_size)) * 3;    /* for each group, compute the minimum exponent */    exp1[0] = exp[0]; /* DC exponent is handled separately */    k = 1;    for(i=1;i<=nb_groups;i++) {        exp_min = exp[k];        assert(exp_min >= 0 && exp_min <= 24);        for(j=1;j<group_size;j++) {            if (exp[k+j] < exp_min)                exp_min = exp[k+j];        }        exp1[i] = exp_min;        k += group_size;    }    /* constraint for DC exponent */    if (exp1[0] > 15)        exp1[0] = 15;    /* Iterate until the delta constraints between each groups are       satisfyed. I'm sure it is possible to find a better algorithm,       but I am lazy */    do {        recurse = 0;        for(i=1;i<=nb_groups;i++) {            delta = exp1[i] - exp1[i-1];            if (delta > 2) {                /* if delta too big, we encode a smaller exponent */                exp1[i] = exp1[i-1] + 2;            } else if (delta < -2) {                /* if delta is too small, we must decrease the previous               exponent, which means we must recurse */                recurse = 1;                exp1[i-1] = exp1[i] + 2;            }        }    } while (recurse);        /* now we have the exponent values the decoder will see */    encoded_exp[0] = exp1[0];    k = 1;    for(i=1;i<=nb_groups;i++) {        for(j=0;j<group_size;j++) {            encoded_exp[k+j] = exp1[i];        }        k += group_size;    }    #if defined(DEBUG)    av_log(AV_LOG_DEBUG, "exponents: strategy=%d\n", exp_strategy);    for(i=0;i<=nb_groups * group_size;i++) {        av_log(AV_LOG_DEBUG, "%d ", encoded_exp[i]);    }    av_log(AV_LOG_DEBUG, "\n");#endif    return 4 + (nb_groups / 3) * 7;}