SVG spec (http://www.w3.org/TR/SVG11/filters.html#feDisplacementMap) states that pixel values must be alpha-demultiplied before processing this filter operation.
The following code does it, but when we DON'T do it, output is more similar to output from Batik.
if (map->mode == NR_PIXBLOCK_MODE_R8G8B8A8P){
alpha = (unsigned int) map_data[4*((x-x0) + width*(y-y0)) + 3];
if (alpha==0){
coordx = x-x0;
coordy = y-y0;
} else {
coordx = x-x0 + scale * ( ((double)NR_DEMUL_111( (unsigned int)map_data[4*((x-x0) + width*(y-y0)) + Xchannel], alpha))/255 -
0.5 );
coordy = y-y0 + scale * ( ((double)NR_DEMUL_111( (unsigned int)map_data[4*((x-x0) + width*(y-y0)) + Ychannel], alpha))/255 - 0.5 );
}
}
Batik output:
http://bighead.poli.usp.br/~juca/code/inkscape/batik-fed02.png
Inkscape output without demultiplication:
http://bighead.poli.usp.br/~juca/code/inkscape/displacement-map-test.png
There is also this other bug that can be seen in the above screenshot: the lower and the right portions are not rendered, I dont know why.
JucaBlues