Page 4 of 4

Re: libjpeg-turbo static

Posted: Fri Jul 08, 2016 4:08 pm
by wilbert
I tried to compile the 1.5.0 version today but it's complicated.
I disabled buffer security check, commented out the putenv and all printf variations from the turbojpeg.c source, added the line for the __iob_func but keep getting four unresolved external symbol errors.

__stdio_common_vsscanf
__stdio_common_vfprintf
__acrt_iob_func
__stdio_common_vsprintf

The scanf and printf variations apparently are also used in another file but I have no idea how I can easily know which source file.
The __acrt_iob_func I have no clue about.

Re: libjpeg-turbo static

Posted: Fri Jul 08, 2016 4:19 pm
by Keya
try compiling one of the older ones like 1.4.2, im wondering if your errors are new to 1.5

searching for "_iob" found refs to a boolean variable need_iobuffer, perhaps its that and setting it to FALSE might turn it off but im not sure if its a compiler directive

btw also turn Whole Program Optimization off if you havent already

the vfprintf/vscanf ones i originally fixed simply by commenting them out

Re: libjpeg-turbo static

Posted: Fri Jul 08, 2016 6:06 pm
by wilbert
I got it working now by removing a bit of code.
It means some environment variables aren't working anymore but I wasn't using those anyway.

The code I had to remove or comment was in three different files.
turbojpeg.c
jerror.c
jmemmgr.c


Once removed, the __acrt_iob_func missing symbol error disappeared by itself.

Re: libjpeg-turbo static

Posted: Fri Jul 08, 2016 9:08 pm
by Keya
Great work!!! how good does it feel when the darn thing finally compiles, 0 errors lol

I just tried it on XP using the source code from the 1st post in this thread, but that demo doesnt really do anything I can test - there's no code for showing the image, although handle=tjInitDecompress() returns valid handle anyway and there were no compiler alerts so im guessing its all good, but if you have some demo code that shows the jpeg thatd be good to test (im sure its just a simple call to ShowImage or whatever but i gather youve already got the code for that!)

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 6:25 am
by wilbert
Here's an encode example you can use to test

Code: Select all

#LIBTURBO = "turbojpeg-static_win32.lib"

Enumeration
  #TJPF_RGB    
  #TJPF_BGR    
  #TJPF_RGBX    
  #TJPF_BGRX
  #TJPF_XBGR
  #TJPF_XRGB
  #TJPF_GRAY
  #TJPF_RGBA
  #TJPF_BGRA
EndEnumeration

Enumeration
  #TJSAMP_444    
  #TJSAMP_422    
  #TJSAMP_420    
EndEnumeration

#TJFLAG_BOTTOMUP    = 2
#TJFLAG_FASTDCT     = 2048
#TJFLAG_ACCURATEDCT = 4096

ImportC #LIBTURBO
  tjAlloc(bytes)
  tjCompress2.l(handle, *srcBuf, width, pitch, height, pixelFormat, *p_jpegBuf, *jpegSize, jpegSubsamp, jpegQual, flags)
  tjDecompress2.l(handle, *jpegBuf, jpegSize, *dstBuf, width, pitch, height, pixelFormat, flags)
  tjDecompressHeader3.l(handle, *jpegBuf, jpegSize, *width, *height, *jpegSubsamp, *jpegColorspace)
  tjFree(*buffer)
  tjGetErrorStr()   
  tjInitCompress()
  tjInitDecompress()
EndImport

; generate image data

Dim ImageData.l(255, 255)

For y = 0 To 255
  For x = 0 To 255
    ImageData(y, x) = x << 16 | y << 8 | (x ! y)
  Next
Next

; write jpeg file

tjC = tjInitCompress()

*buffer = 0
If tjCompress2(tjC, @ImageData(), 256, 1024, 256, #TJPF_RGBX, @*buffer, @size, #TJSAMP_444, 95, #TJFLAG_ACCURATEDCT) = 0
  If CreateFile(0, "libturbojpeg_test.jpg")
    WriteData(0, *buffer, size)
    CloseFile(0)
  EndIf
  tjFree(*buffer)
EndIf

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 6:41 am
by Keya
yep thats working fine, and amazing image from hardly any code!

Code: Select all

For y = 0 To 255
  For x = 0 To 255
    ImageData(y, x) = x << 16 | y << 8 | (x ! y)
  Next
Next
Image

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 7:34 am
by wilbert
Thanks Keya. :)

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 8:48 am
by fryquez
Works here with WinXPx64 and Win7x64.

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 10:17 am
by wilbert
fryquez wrote:Works here with WinXPx64 and Win7x64.
Thank you very much for testing :)
Good to know it is working cross platform.

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 5:58 pm
by netmaestro
Win 7 pro sp1 x64: Appears working perfectly. Thanks for your efforts on this Wilbert! 8)

Re: libjpeg-turbo static

Posted: Sat Jul 09, 2016 6:17 pm
by wilbert
netmaestro wrote:Win 7 pro sp1 x64: Appears working perfectly. Thanks for your efforts on this Wilbert! 8)
Thanks netmaestro :)
Keya did a lot of the problem solving when it comes to the Windows version.
I like this lib a lot. You have more control of the output compared to what PB offers, it's cross platform and very fast.
I just read an article from the developer that he is working on AVX2 support for newer processors and expects a 20 - 30% performance increase for that. 8)
https://sourceforge.net/blog/may-2016-c ... peg-turbo/