FilterFactory - Function "r2x"

Back to function listing

x displacement of the pixel m units away, at an angle of d, from an arbitrary center

Syntax

r2x(d,m)

Original Machine Code (in OPER resource) of Filter Factory 3.0 and 3.0.4 for Photoshop/Win32

58 pop eax (param_m) .
5B pop ebx (param_d) .
81 E3 FF 03 00 00 and ebx,$000003ff (1023) param_m %= 1024; // param_m &= 0x3FF;
0F BF 9C 5F 78 05 00 00 movsx ebx,[edi+ebx*2+$00000578] (COS_LOOKUP) param_d = COS_LOOKUP[param_d];
F7 EB imul ebx edx:eax = param_b * param_d
05 FF 1F 00 00 add eax,$00001fff (8191) param_m += 0x1FFF;
83 D2 00 adc edx,$00 (0) if (cf is set) edx++
0F AC D0 0E shrd eax,edx,$0e (14) Shift EAX right by 14 bits
Store lower 14 bits of EDX into the upper 14 bits of EAX
50 push eax return param_m;

C++ code

int factory_r2x(int d, int m) {
	int eax = m;
	int ebx = d;
	ebx &= 1023;
	ebx = COS_LOOKUP[ebx];
	eax = (((int64_t)eax * (int64_t)ebx) + 8191) >> 14;
	return eax;
}