[XviD-devel] SAD cache
skal
skal at planet-d.net
Tue Mar 11 12:23:35 CET 2003
On Tue, 2003-03-11 at 11:58, Radek Czyz wrote:
> Hi,
> skal wrote,
>
> > so far I've seen, it's 10-20% hits for 'regular' fast moving
> > scenes. For slow moving ones (where the diamond/square search
> > does not wander too far), it raises up to 20-30%. Conversely,
> > for 'hard' scenes, it drops to 5%.
>
> Ooooops, there must be a bug - a big one ;_; .
>
Don't rush! These figures are for the SAD-cache in full action,
using a dull search function that would look like:
void Eval_Dir(SAD_CACHE * const C, int x, int y, int Dir, int * const New_Dir)
{
if (Sad_Is_Tested(C, x,y)) return;
uint32_t Sad = sad16(C->Src, C->Ref+x+y*C->stride, C->stride);
if (Sad<C->Best_Sad) {
Cache_Sad(C, x,y,Sad);
*New_Dir = (*New_Dir & 0xff) | Dir;
}
}
int MV_Search(SAD_CACHE * const C, const VECTOR v)
{
int Dir = 0;
const uint32_t Best_Sad = C->Best_Sad;
Dir = 0x0;
while(1) {
int x = C->Best_MV.x;
int y = C->Best_MV.y;
if (x<C->xMax && !(Dir&0x02)) Eval_Dir(C, x+1,y, 0x100, &Dir);
if (x>C->xmin && !(Dir&0x01)) Eval_Dir(C, x-1,y, 0x200, &Dir);
if (y<C->yMax && !(Dir&0x08)) Eval_Dir(C, x, y+1,0x400, &Dir);
if (y>C->ymin && !(Dir&0x04)) Eval_Dir(C, x, y-1,0x800, &Dir);
if (Dir&0xf00) // check corners now, if new dir was found
{
x = C->Best_MV.x;
y = C->Best_MV.y;
if (Dir&0x300) {
Eval_Dir(C, x, y+1,0x400, &Dir);
Eval_Dir(C, x, y-1,0x800, &Dir);
}
else {
Eval_Dir(C, x+1, y,0x100, &Dir);
Eval_Dir(C, x-1, y,0x200, &Dir);
}
Dir >>= 8;
}
else break;
}
return (C->Best_Sad<Best_Sad); // success?
}
The ones in xvid are more refined than this :)
bye,
Skal
More information about the XviD-devel
mailing list