libjpeg-turbo static

Windows specific forum
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: libjpeg-turbo static

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: libjpeg-turbo static

Post 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
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: libjpeg-turbo static

Post 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.
Last edited by wilbert on Sat Jul 09, 2016 7:24 am, edited 1 time in total.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: libjpeg-turbo static

Post 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!)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: libjpeg-turbo static

Post 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
Last edited by wilbert on Sat Jul 09, 2016 7:24 am, edited 1 time in total.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: libjpeg-turbo static

Post 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
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: libjpeg-turbo static

Post by wilbert »

Thanks Keya. :)
Last edited by wilbert on Wed May 31, 2017 2:58 pm, edited 1 time in total.
Windows (x64)
Raspberry Pi OS (Arm64)
fryquez
Enthusiast
Enthusiast
Posts: 369
Joined: Mon Dec 21, 2015 8:12 pm

Re: libjpeg-turbo static

Post by fryquez »

Works here with WinXPx64 and Win7x64.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: libjpeg-turbo static

Post by wilbert »

fryquez wrote:Works here with WinXPx64 and Win7x64.
Thank you very much for testing :)
Good to know it is working cross platform.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: libjpeg-turbo static

Post by netmaestro »

Win 7 pro sp1 x64: Appears working perfectly. Thanks for your efforts on this Wilbert! 8)
BERESHEIT
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: libjpeg-turbo static

Post 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/
Windows (x64)
Raspberry Pi OS (Arm64)
Post Reply