[Solved] Same C code, different result on x86 and ARM


Linux-SWAT

Hardcore Member
Joined
Feb 13, 2010
Messages
8,815
Hi,

this is a Sobel filter.
It compiles on x86_64 and ARM 32 and 64, and must be used with a 8bit grayscale .bmp .

The problem is that the execution on ARM 32 and 64 produces a garbage image, and I have absolutely no idea why.

I tried GCC 5 and 7 on ARM64.

Any thoughts ?
 

Attachments

  • sobel.zip
    1.9 KB · Views: 195

elvissteinjr

Very Active Member
Joined
Jun 19, 2010
Messages
754
Age
24
Location
Germany
I didn't test the code, but to me it looks like the unaligned memory access you do with the short pointers may be the culprit. You can get away with that on x86, but not ARM iirc.
 

ptitSeb

Serial Porter
Joined
Aug 15, 2012
Messages
8,851
Age
48
Location
France, near Lyon
Maybe it's just the structure that need packing.
try to add
Code:
#pragma pack(push, 1)
befor the definition of the struct in the .h
and
Code:
#pragma pack(pop)
aftrer the definition
 
Top