From: Andre Noll Date: Sat, 7 Nov 2009 14:39:25 +0000 (+0100) Subject: wma: Clean up compute_high_band_values(). X-Git-Tag: v0.4.1~35 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=b629661a56a97563a784b305e76d2b6c6bc7e7cc;p=paraslash.git wma: Clean up compute_high_band_values(). This reduces the indentation quite a bit and makes the code much more readable. --- diff --git a/wmadec_filter.c b/wmadec_filter.c index 8c9132eb..fccd8907 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -683,56 +683,46 @@ static int compute_high_band_values(struct private_wmadec_data *pwd, { int ch; - if (pwd->use_noise_coding) { - for (ch = 0; ch < pwd->ahi.channels; ch++) { - if (pwd->channel_coded[ch]) { - int i, m, a; - m = pwd->exponent_high_sizes[bsize]; - for (i = 0; i < m; i++) { - a = get_bit(&pwd->gb); - pwd->high_band_coded[ch][i] = a; - /* if noise coding, the coefficients are not transmitted */ - if (a) - nb_coefs[ch] -= - pwd-> - exponent_high_bands[bsize] - [i]; - } - } + if (!pwd->use_noise_coding) + return 0; + for (ch = 0; ch < pwd->ahi.channels; ch++) { + int i, m, a; + if (!pwd->channel_coded[ch]) + continue; + m = pwd->exponent_high_sizes[bsize]; + for (i = 0; i < m; i++) { + a = get_bit(&pwd->gb); + pwd->high_band_coded[ch][i] = a; + if (!a) + continue; + nb_coefs[ch] -= pwd->exponent_high_bands[bsize][i]; } - for (ch = 0; ch < pwd->ahi.channels; ch++) { - if (pwd->channel_coded[ch]) { - int i, n, val; - - n = pwd->exponent_high_sizes[bsize]; - val = (int) 0x80000000; - for (i = 0; i < n; i++) { - if (pwd->high_band_coded[ch][i]) { - if (val == (int) 0x80000000) { - val = - get_bits(&pwd->gb, - 7) - 19; - } else { - int code = - get_vlc(&pwd->gb, - pwd-> - hgain_vlc. - table, - HGAINVLCBITS, - HGAINMAX); - if (code < 0) - return -1; - val += code - 18; - } - pwd->high_band_values[ch][i] = - val; - } - } + } + for (ch = 0; ch < pwd->ahi.channels; ch++) { + int i, n, val; + if (!pwd->channel_coded[ch]) + continue; + n = pwd->exponent_high_sizes[bsize]; + val = (int)0x80000000; + for (i = 0; i < n; i++) { + if (!pwd->high_band_coded[ch][i]) + continue; + if (val == (int)0x80000000) + val = get_bits(&pwd->gb, 7) - 19; + else { + int code = get_vlc(&pwd->gb, + pwd->hgain_vlc.table, HGAINVLCBITS, + HGAINMAX); + if (code < 0) + return -1; + val += code - 18; } + pwd->high_band_values[ch][i] = val; } } return 1; } + /** * @return 0 if OK. 1 if last block of frame. return -1 if * unrecorrable error.