From a3359f5d2c736b8e5a3fc5f9194c845de6b46d46 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 10 Dec 2013 05:36:23 +0100 Subject: [PATCH] Only compute quantization params once (all quantization params #1..#15 are the same) Change-Id: If04058bd89fe2677b5b118ee4e1bcce88f0e4bf5 --- src/enc/quant.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/enc/quant.c b/src/enc/quant.c index 3f1ae8e7..3ad49499 100644 --- a/src/enc/quant.c +++ b/src/enc/quant.c @@ -188,12 +188,8 @@ static const uint8_t kFreqSharpening[16] = { // Returns the average quantizer static int ExpandMatrix(VP8Matrix* const m, int type) { - int i; - int sum = 0; - for (i = 2; i < 16; ++i) { - m->q_[i] = m->q_[1]; - } - for (i = 0; i < 16; ++i) { + int i, sum; + for (i = 0; i < 2; ++i) { const int is_ac_coeff = (i > 0); const int bias = kBiasMatrices[type][is_ac_coeff]; m->iq_[i] = (1 << QFIX) / m->q_[i]; @@ -202,6 +198,14 @@ static int ExpandMatrix(VP8Matrix* const m, int type) { // * zero if coeff <= zthresh // * non-zero if coeff > zthresh m->zthresh_[i] = ((1 << QFIX) - 1 - m->bias_[i]) / m->iq_[i]; + } + for (i = 2; i < 16; ++i) { + m->q_[i] = m->q_[1]; + m->iq_[i] = m->iq_[1]; + m->bias_[i] = m->bias_[1]; + m->zthresh_[i] = m->zthresh_[1]; + } + for (sum = 0, i = 0; i < 16; ++i) { if (type == 0) { // we only use sharpening for AC luma coeffs m->sharpen_[i] = (kFreqSharpening[i] * m->q_[i]) >> SHARPEN_BITS; } else {