Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- ; esi -> edi, ecx = line width
- ; return = (4*Pxl(x,y)+3*Pxl(x-1,y)+3*Pxl(x+1,y)+3*Pxl(x,y+1)+3*Pxl(x,y-1))/16
- ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- _WaveGetPixel:
- movzx eax,byte ptr [esi]
- shl eax,2
- movzx edx,byte ptr [esi+3]
- lea edx,[edx+2*edx]
- add eax,edx
- movzx edx,byte ptr [esi-3]
- lea edx,[edx+2*edx]
- add eax,edx
- movzx edx,byte ptr [esi+ecx]
- lea edx,[edx+2*edx]
- add eax,edx
- mov edx,esi
- sub edx,ecx
- movzx edx,byte ptr [edx]
- lea edx,[edx+2*edx]
- add eax,edx
- shr eax,4
- mov [edi],al
- inc esi
- inc edi
- ret
- */
- typedef unsigned char byte;
- typedef unsigned int u32;
- void
- WaveGetPixel_1(byte *dst,const byte *src,u32 stride)
- {
- u32 sum = 0;
- u32 pix;
- // (4 * Pxl(x,y) +
- // 3 * Pxl(x-1,y) +
- // 3 * Pxl(x+1,y) +
- // 3 * Pxl(x,y+1) +
- // 3 * Pxl(x,y-1)) / 16
- //
- // convolution kernel:
- //
- // +----+----+----+
- // | | 3A | |
- // +----+----+----+
- // | 3L | 4C | 3R |
- // +----+----+----+
- // | | 3B | |
- // +----+----+----+
- // 4 * Pxl(x,y)
- // current pixel (4C)
- pix = src[0];
- pix <<= 2;
- sum += pix;
- // 3 * Pxl(x-1,y)
- // pixel to the left (3L)
- pix = src[-1];
- pix *= 3;
- sum += pix;
- // 3 * Pxl(x+1,y)
- // pixel to the right (3R)
- pix = src[1];
- pix *= 3;
- sum += pix;
- // 3 * Pxl(x,y+1)
- // pixel below (3B)
- pix = src[stride];
- pix *= 3;
- sum += pix;
- // 3 * Pxl(x,y-1)
- // pixel above (3A)
- pix = src[-stride];
- pix *= 3;
- sum += pix;
- // / 16
- sum >>= 4;
- dst[0] = sum;
- }
- void
- WaveGetPixel_3(byte *dst,const byte *src,u32 stride)
- {
- // do red
- WaveGetPixel_1(dst++,src++,stride);
- // do green
- WaveGetPixel_1(dst++,src++,stride);
- // do blue
- WaveGetPixel_1(dst++,src++,stride);
- }
Advertisement
Add Comment
Please, Sign In to add comment