mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-15 21:39:59 +02:00
move the quantization function to dsp.c
and add a function pointer for it Change-Id: Ic7012e35c74a474bf140bb23cdaf9d6950026bc6
This commit is contained in:
@ -581,6 +581,38 @@ static int Disto16x16(const uint8_t* const a, const uint8_t* const b,
|
||||
VP8WMetric VP8TDisto4x4 = Disto4x4;
|
||||
VP8WMetric VP8TDisto16x16 = Disto16x16;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Quantization
|
||||
//
|
||||
|
||||
// Simple quantization
|
||||
static int QuantizeBlock(int16_t in[16], int16_t out[16],
|
||||
int n, const VP8Matrix* const mtx) {
|
||||
int last = -1;
|
||||
for (; n < 16; ++n) {
|
||||
const int j = VP8Zigzag[n];
|
||||
const int sign = (in[j] < 0);
|
||||
int coeff = (sign ? -in[j] : in[j]) + mtx->sharpen_[j];
|
||||
if (coeff > 2047) coeff = 2047;
|
||||
if (coeff > mtx->zthresh_[j]) {
|
||||
const int Q = mtx->q_[j];
|
||||
const int iQ = mtx->iq_[j];
|
||||
const int B = mtx->bias_[j];
|
||||
out[n] = QUANTDIV(coeff, iQ, B);
|
||||
if (sign) out[n] = -out[n];
|
||||
in[j] = out[n] * Q;
|
||||
if (out[n]) last = n;
|
||||
} else {
|
||||
out[n] = 0;
|
||||
in[j] = 0;
|
||||
}
|
||||
}
|
||||
return (last >= 0);
|
||||
}
|
||||
|
||||
// default C implementation
|
||||
VP8QuantizeBlock VP8EncQuantizeBlock = QuantizeBlock;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Block copy
|
||||
|
||||
@ -606,7 +638,6 @@ VP8BlockCopy VP8Copy16x16 = Copy16x16;
|
||||
|
||||
void VP8EncDspInit() {
|
||||
InitTables();
|
||||
// later we'll plug some SSE2 variant here
|
||||
}
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
|
Reference in New Issue
Block a user