[XviD-devel] Proposed patch

carlo.bramix carlo.bramix at libero.it
Mon Nov 5 18:16:41 CET 2007


Hello,
I must say that I didn't a speed test on the saturation of the quantizer with LUT.
Actually, it looked nicer since previous code had to do an addition, two comparisons and two conditional jumps on a plain x86 (best case), while this one do everything, addition & clipping, with a single mov opcode.
It could be better an "hybrid" fix with an #ifdef on DQUANT_SAT macro definition and preserve current solution too:

#if 1 // to decide how to do so...
static int __inline DQUANT_SAT(int quant)
{
    if (quant > 31)
        quant = 31;
    else
    if (quant < 1)
        quant = 1;
    return quant;
}
#else
static const int32_t dquant_table[4] = {
  -1, -2, 1, 2
};
#define DQUANT_SAT(_quant)  dquant_saturate[(_quant) + 1]
static const unsigned char dquant_saturate[] = {
  1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
  23, 24, 25, 26, 27, 28, 29, 30, 31, 31, 31,
};
#endif

because I admit that it also depends on the hardware platform: ARM and PowerPC versions will work better with previous code instead, otherwise they need to load address of dquant_saturate[] vector too.
Or, more easily, you can just throw that idea of clipping...
Even if there could be an hypothetical benefit, I don't think it will change the life of the users!

Sincerely,

Carlo Bramini.

---------- Initial Header -----------



More information about the XviD-devel mailing list