/* Replaces 8 elements with their average value. Called by qdm2_decode_superblock before starting subblock decoding. */
static void average_quantized_coeffs(QDM2Context *q)
/* Replaces 8 elements with their average value. Called by qdm2_decode_superblock before starting subblock decoding. */
static void average_quantized_coeffs(QDM2Context *q)
{
    int i, j, n, ch, sum;
    n = coeff_per_sb_for_avg[q->coeff_per_sb_select][QDM2_SB_USED(q->sub_sampling) - 1] + 1;
    for (ch = 0; ch < q->nb_channels; ch++)
        for (i = 0; i < n; i++) {
            sum = 0;
            for (j = 0; j < 8; j++)
                sum += q->quantized_coeffs[ch][i][j];
            sum /= 8;
            if (sum > 0)
                sum--;
            for (j=0; j < 8; j++)
                q->quantized_coeffs[ch][i][j] = sum;
        }
}