20% faster lpc, 6% overall flac decoding

Originally committed as revision 10627 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Loren Merritt 2007-09-30 03:01:56 +00:00
parent 08965b22e2
commit d1a5c4216c
1 changed files with 18 additions and 15 deletions

View File

@ -315,6 +315,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
int i, j; int i, j;
int coeff_prec, qlevel; int coeff_prec, qlevel;
int coeffs[pred_order]; int coeffs[pred_order];
int32_t *decoded = s->decoded[channel];
// av_log(s->avctx, AV_LOG_DEBUG, " SUBFRAME LPC\n"); // av_log(s->avctx, AV_LOG_DEBUG, " SUBFRAME LPC\n");
@ -323,8 +324,8 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
for (i = 0; i < pred_order; i++) for (i = 0; i < pred_order; i++)
{ {
s->decoded[channel][i] = get_sbits(&s->gb, s->curr_bps); decoded[i] = get_sbits(&s->gb, s->curr_bps);
// av_log(s->avctx, AV_LOG_DEBUG, " %d: %d\n", i, s->decoded[channel][i]); // av_log(s->avctx, AV_LOG_DEBUG, " %d: %d\n", i, decoded[i]);
} }
coeff_prec = get_bits(&s->gb, 4) + 1; coeff_prec = get_bits(&s->gb, 4) + 1;
@ -356,32 +357,34 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
{ {
sum = 0; sum = 0;
for (j = 0; j < pred_order; j++) for (j = 0; j < pred_order; j++)
sum += (int64_t)coeffs[j] * s->decoded[channel][i-j-1]; sum += (int64_t)coeffs[j] * decoded[i-j-1];
s->decoded[channel][i] += sum >> qlevel; decoded[i] += sum >> qlevel;
} }
} else { } else {
for (i = pred_order; i < s->blocksize-1; i += 2) for (i = pred_order; i < s->blocksize-1; i += 2)
{ {
int c = coeffs[pred_order-1]; int c;
int s0 = c * s->decoded[channel][i-pred_order]; int d = decoded[i-pred_order];
int s1 = 0; int s0 = 0, s1 = 0;
for (j = pred_order-1; j > 0; j--) for (j = pred_order-1; j > 0; j--)
{ {
int d = s->decoded[channel][i-j]; c = coeffs[j];
s1 += c*d;
c = coeffs[j-1];
s0 += c*d; s0 += c*d;
d = decoded[i-j];
s1 += c*d;
} }
s0 = s->decoded[channel][i] += s0 >> qlevel; c = coeffs[0];
s1 += c * s0; s0 += c*d;
s->decoded[channel][i+1] += s1 >> qlevel; d = decoded[i] += s0 >> qlevel;
s1 += c*d;
decoded[i+1] += s1 >> qlevel;
} }
if (i < s->blocksize) if (i < s->blocksize)
{ {
int sum = 0; int sum = 0;
for (j = 0; j < pred_order; j++) for (j = 0; j < pred_order; j++)
sum += coeffs[j] * s->decoded[channel][i-j-1]; sum += coeffs[j] * decoded[i-j-1];
s->decoded[channel][i] += sum >> qlevel; decoded[i] += sum >> qlevel;
} }
} }