BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help compiling NASM source for a x86 SIMD optimized Jpeg uni

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM
View previous topic :: View next topic  
Author Message
Andrea M.
Guest





PostPosted: Mon Apr 30, 2007 12:12 am    Post subject: Help compiling NASM source for a x86 SIMD optimized Jpeg uni Reply with quote



Greetings,
I've found an optimized (very fast!) version of the standard JPEG library.
http://cetus.sakura.ne.jp/softlab/jpeg-x86simd/jpegsimd.html
"The JPEG library in this distribution uses SIMD instructions
if available. On a processor that supports SIMD instructions (MMX, SSE,
etc), it runs 2-3 times faster than the original version of JPEG library."
It's Japanese, but it's simple understand what is needed to download ;)

I've successfully compiled the library with the free Borland BCC5.5, and
now I have the .obj needed by Delphi jpeg unit wrapper.
But the NASM (Netwide Assembler) .obj seems incompatible with Delphi linker
(directive $L} ) "Bad object file format xxxxxx.obj" is the error.
Searching on internet seems that "DELPHI linker is quite picky"...
I tried several solution and finally get rid of this error "bad object
format..." ... but another one appear "Unsatisfied forward or external
declaration ..." this time for C++ obj file Sad
Someone have an idea how link these objs?
Can be interesting this project? I think if work we can have a very fast
jpeg unit!

Andrea
Back to top
Bob Gonder
Guest





PostPosted: Tue May 08, 2007 9:32 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote



Andrea M. wrote:

Quote:
The problem are the .obj files.
I'm trying to modify the jpeglib.h right now...but still the same error
"Unsatisfied forward or external..."

Doesn't it go on to state exactly which externals are missing?
The real clues are in what the message actually says.
Without knowing the full message. speculation is unfounded.
Back to top
Andrea M.
Guest





PostPosted: Wed May 09, 2007 6:54 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote



On Tue, 08 May 2007 09:32:43 -0700, Bob Gonder wrote:
Quote:
Doesn't it go on to state exactly which externals are missing?
The real clues are in what the message actually says.
Without knowing the full message. speculation is unfounded.
well, you are right... but ALL the functions declared as external are

"unsatisfied".

procedure jpeg_CreateDecompress (var cinfo : jpeg_decompress_struct;
version : integer; structsize : integer); {$IFDEF LINUX} cdecl; {$ENDIF}
external {$IFDEF JPEGSO} 'libjpeg.so' name 'jpeg_CreateDecompress'
{$ENDIF};

and this is the error

[Error] jpeg.pas(862): Unsatisfied forward or external declaration:
'jpeg_CreateDecompress'

The error is the same for all the functions
jpeg_stdio_src
jpeg_read_header
jpeg_calc_output_dimensions
etc.

if I rename, prefixing them with underscore
procedure _jpeg_CreateDecompress (...

it's ok, but still remains other "Unsatisfied forward or external
declaration":
[Error] jpeg.pas(1945): ... '_getenv'
[Error] jpeg.pas(1945): ... '_sscanf'

and

[Error] jpeg.pas(1945): ... '_jconst_merged_upsample_sse2'
[Error] jpeg.pas(1945): ... '_jpeg_h2v2_merged_upsample_sse2'

those last are for NASM generated obj, but they are not linked directly by
Delphi code.

I've already used NASM and C obj linking them in delphi without any
problem, so I do not know why this library is so difficult to link.

Andrea
Back to top
Bob Gonder
Guest





PostPosted: Wed May 09, 2007 9:17 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

Andrea M. wrote:

Quote:
well, you are right... but ALL the functions declared as external are
"unsatisfied".

Either naming problems, or you aren't including the proper libs

Quote:
[Error] jpeg.pas(862): Unsatisfied forward or external declaration:
'jpeg_CreateDecompress'
jpeg_stdio_src
jpeg_read_header
jpeg_calc_output_dimensions
etc.
if I rename, prefixing them with underscore
procedure _jpeg_CreateDecompress (...
it's ok,

Ok, so those are C functions then?
C function names default to leading underscore.

Quote:
but still remains other "Unsatisfied forward or external
declaration":
[Error] jpeg.pas(1945): ... '_getenv'
[Error] jpeg.pas(1945): ... '_sscanf'

C runtime library functions. You probably didn't include the CRTL
You could either replace those functions with WinApi functions, or add
the appropriate lib to your link.

Quote:
[Error] jpeg.pas(1945): ... '_jconst_merged_upsample_sse2'
[Error] jpeg.pas(1945): ... '_jpeg_h2v2_merged_upsample_sse2'

those last are for NASM generated obj, but they are not linked directly by
Delphi code.

And does your NASM source have the leading underscores in the names?
Back to top
Andrea M.
Guest





PostPosted: Thu May 10, 2007 1:06 am    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

On Wed, 09 May 2007 09:17:06 -0700, Bob Gonder wrote:
Quote:
Andrea M. wrote:
if I rename, prefixing them with underscore
procedure _jpeg_CreateDecompress (...
it's ok,

Ok, so those are C functions then?
C function names default to leading underscore.
yes, they are all C functions and must be prefixed by an underscore,

thanks.
Now, the C functions names are solved.

Quote:
but still remains other "Unsatisfied forward or external
declaration":
[Error] jpeg.pas(1945): ... '_getenv'
[Error] jpeg.pas(1945): ... '_sscanf'
C runtime library functions. You probably didn't include the CRTL
You could either replace those functions with WinApi functions, or add
the appropriate lib to your link.
I see, but in the original unit there is no need for those functions... and

I wonder what a sscanf and getenv can be useful to a decompressor...
But this is not a problem right now, I can replace them with dummy or real
functions.

The problem is NASM obj
Quote:
[Error] jpeg.pas(1945): ... '_jconst_merged_upsample_sse2'
[Error] jpeg.pas(1945): ... '_jpeg_h2v2_merged_upsample_sse2'

And does your NASM source have the leading underscores in the names?
yes


I've declared in delphi source

{$L .\obj\jdmerss2.obj}
procedure _jpeg_h2v2_merged_upsample_sse2(
var cinfo: jpeg_decompress_struct;
input_buf: JSAMPIMAGE;
in_row_group_ctr: JDIMENSION;
output_buf: JSAMPARRAY); external;

and from the jdmerss2.asm:

; jpeg_h2v2_merged_upsample_sse2 (j_decompress_ptr cinfo,
; JSAMPIMAGE input_buf,
; JDIMENSION in_row_group_ctr,
; JSAMPARRAY output_buf);
%define cinfo(b) (b)+8 ; j_decompress_ptr cinfo
%define input_buf(b) (b)+12 ; JSAMPIMAGE input_buf
%define in_row_group_ctr(b) (b)+16 ; JDIMENSION in_row_group_ctr
%define output_buf(b) (b)+20 ; JSAMPARRAY output_buf
align 16
global EXTN(jpeg_h2v2_merged_upsample_sse2)
EXTN(jpeg_h2v2_merged_upsample_sse2):

where EXTN is a macro defined as

%define EXTN(name) _ %+ name ; foo() -> _foo

I still receive
Unsatisfied forward ... : '_jpeg_h2v2_merged_upsample_sse2'

I do not know, I think the Delphi declaration is correct, so where I'm
wrong?

Andrea
Back to top
Bob Gonder
Guest





PostPosted: Thu May 10, 2007 7:33 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

Andrea M. wrote:

Quote:
The problem is NASM obj
[Error] jpeg.pas(1945): ... '_jpeg_h2v2_merged_upsample_sse2'
I've declared in delphi source

If your ASM functions are not needed by the C code, then just use them
without the underscores. The leading underscore is for C compatability
(ease of use in C).

Quote:
global EXTN(jpeg_h2v2_merged_upsample_sse2)
EXTN(jpeg_h2v2_merged_upsample_sse2):

global _jpeg_h2v2_merged_upsample_sse2
_jpeg_h2v2_merged_upsample_sse2:

Quote:
I still receive
Unsatisfied forward ... : '_jpeg_h2v2_merged_upsample_sse2'

Did you add the NASM obj to your linker step properly?
Probably by adding it to your project? (I dont believe in magic {$L} )

Then too, you can use TDump to see the exported names in your *.obj
files.
Back to top
Sascha Buchner
Guest





PostPosted: Wed May 16, 2007 2:55 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

Hi,

would you mind posting the results of your work?
I would like to try it with Delphi.

thank you
Sascha
Back to top
Andrea M.
Guest





PostPosted: Wed May 16, 2007 6:20 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

On Thu, 10 May 2007 07:33:51 -0700, Bob Gonder wrote:
Quote:
If your ASM functions are not needed by the C code, then just use them
without the underscores. The leading underscore is for C compatability
(ease of use in C).
no, the ASM function are only called by C code


Quote:
Did you add the NASM obj to your linker step properly?
Probably by adding it to your project? (I dont believe in magic {$L} )
I think object are linked correctly, in fact, if I use the original .obj

distribuited by Borland the unit compile correctly.

Quote:
Then too, you can use TDump to see the exported names in your *.obj
files.
Names seems exported correctly.


000064 PUBDEF '_jconst_merged_upsample_sse2' Segment: DATA:0000
00008A PUBDEF '_jpeg_h2v1_merged_upsample_sse2' Segment: CODE:0000
PUBDEF '_jpeg_h2v2_merged_upsample_sse2' Segment: CODE:03A0
0000D6 COMENT Purge: Yes, List: No , Class: 162 (0A2h)

Thanks again for your suggestion Bob.

Andrea
Back to top
Andrea M.
Guest





PostPosted: Wed May 16, 2007 6:32 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

On Wed, 16 May 2007 11:55:07 +0200, Sascha Buchner wrote:

Quote:
Hi,

would you mind posting the results of your work?
I would like to try it with Delphi.

of course, no problem for me; I've found jpeg.pas freely with Delphi7

Personal, so I assume no problem for Borland too.

http://www.andy2.net/jpeg-ok.7z
here the modified package compilable with the free BCC 5 and NASM.

http://www.andy2.net/pas-jpeg-unit.7z
here the already compiled .obj with the unit jpeg (still not working) with
all obj inclusion {$L} and only the first declaration of NASM function
_jpeg_h2v2_merged_upsample_sse2
to check if work.

Andrea
Back to top
Bob Gonder
Guest





PostPosted: Wed May 16, 2007 7:14 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

Andrea M. wrote:

Quote:
00008A PUBDEF '_jpeg_h2v1_merged_upsample_sse2' Segment: CODE:0000
PUBDEF '_jpeg_h2v2_merged_upsample_sse2' Segment: CODE:03A0

Those might need to be Segment _TEXT

You might want to TDump the one that works and see any difference.
Back to top
Sanyin
Guest





PostPosted: Fri May 18, 2007 7:50 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

"Andrea M." <info (AT) andy2 (DOT) net> wrote in message
news:fg6rbb82tqpi$.1dhkb2mhav46m.dlg (AT) 40tude (DOT) net...
Quote:
On Thu, 10 May 2007 07:33:51 -0700, Bob Gonder wrote:
If your ASM functions are not needed by the C code, then just use them
without the underscores. The leading underscore is for C compatability
(ease of use in C).
no, the ASM function are only called by C code

Any news?
I am trying to make dll interface..but doesnt work, jpeg_decompress
structure is 4 bytes smaller...and I hve corrected it (using dummy
variables), now still cant load jpeg..are dll functions STDCALL exported?
Back to top
Jonathan Benedicto
Guest





PostPosted: Fri May 18, 2007 10:26 pm    Post subject: Re: Help compiling NASM source for a x86 SIMD optimized Jpeg Reply with quote

Sanyin wrote:
Quote:
Any news?
I am trying to make dll interface..but doesnt work, jpeg_decompress
structure is 4 bytes smaller...and I hve corrected it (using dummy
variables), now still cant load jpeg..are dll functions STDCALL exported?

Because the exports (if I followed this thread correctly) have a leading
underscore, they are STDCALL, yes.

Jon
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Language BASM All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.