[XviD-devel] qpel matrices

skal skal at planet-d.net
Mon Aug 30 09:15:26 CEST 2004


	Hi Christoph,

On Sat, 2004-08-28 at 15:56, Christoph Nägeli wrote:
> Hi,
> 
> Perhaps you know, I'm currently porting the new patches from Edouard to 
> altivec and I got some questions about the qpel code (qpel.c) which 
> some of you may answer I think.
> 
> 
> About the definition of the FIR_Tab_16 (and perhaps FIR_Tab_8, too. I'm 
> not yet coding the '8 routines'):
> 
> This Matrix is defined with elements of int32_t though they range just 
> from -7 to 23 so would it be possible to declare it using int8_t or 
> will they change in the future? 

	Actually, Using 32-bits access is just usually faster in C / x86.
	Note, moreover, that the filtering process can be done using 
	16-bits arithmetic only. And, from the theoretical point of
	view, 11-bit arithmetic is enough, even.

> That way I could load one line per 
> vector which leads to the next question. Is there an easy way to create 
> these values on the fly so I don't have to fetch them from a global 
> variable? I don't see any easy trick to generate though in qpel.c, 
> there are tables allocated for mmx which aren't hardcoded so I think 
> they will be generated on the fly (I don't understand x86 assembly so I 
> can't see myself).

	These values are based on 6 weighting coefficients that 
	are the base of the filter: [-1 3 -6 20 20 -6 3 -1].

	That is, given 8 pixel values [a b c d e f g h] around
	the one you're interpolating (the hpel between position
	'd' and 'e' in this example), you accumulate them as:

	Val = -a + 3b -6c + 20d + 20e - 6f + 3g -h

	(and afterward, you round, descale, clip this 'Val').

	Now, you must perform mirroring on the boundary. That's
	why there are some 'strange' values. For instance,
	if pixels 'a' and 'b' are outside of the block's boundary,
	you mirror them using: b=c, a=d (the mirror line is
	halfway between position 'b' and 'c'). Hence:

	-a + 3b -6c + 20d + 20e - 6f + 3g -h = -3c+19d+20e-6f+3g-h

	after mirroring.

	hope it helps,

Skal



More information about the XviD-devel mailing list