BGLDEC - A resample BGL DECompressor

#21
@dave hoeffgen, @denali, Try this latest release and see if it fixes your issues, I did forget to compile in release last time, oops! You will also need the VC++2015 x86 redist as described in the documentation.

@Golf-HotelDelta, interesting that it crashed during decompilation after succeeding with previous PTC chunks. Give this latest build a try with P3Dv3.1 if you can. If there are still issues, is your BGL part of a publicly available package that I can test against?

Thanks for the feedback everyone!
 
Last edited:
#24
OK, I had installed the 64 bit version.

After installing the x86 version it crashed almost immediately:

Code:
G:\BGLDec>bgldec BMP Area_Lm1_SnapOff_N053491069_N053473055_E012122904_E012154692.bgl
BGLDEC v0.5.1 - A BGL DECompressor for resampled data in P3D v3.1

BGL FileName: BMP
Mode:  BIN
Output Directory: Local
 
#25
Flip the arguments around, it's expecting them in order: bgldec inputFile.bgl [BMP|BIN] ["Path\To\Output\Folder"]

Code:
bgldec Area_Lm1_SnapOff_N053491069_N053473055_E012122904_E012154692.bgl BMP
Sorry, there's not really any error checking on the command line yet
 
#26
Closer:

G:\BGLDec>bgldec Area_Lm1_SnapOff_N053491069_N053473055_E012122904_E012154692.bgl BMP
BGLDEC v0.5.1 - A BGL DECompressor for resampled data in P3D v3.1

BGL FileName: Area_Lm1_SnapOff_N053491069_N053473055_E012122904_E012154692.bgl
Mode: BMP
Output Directory: Local

* Input File Read
* BGL Header Read, 13 Sections
* Decompilation Started
* Decompiling Section 0, 21 subsections
* Decompiling Section 1, 3187 subsections

BTW. This file was compiled with the FSX Resample.

Off to bed now :wave:
 
#27
Okay, final sanity check for once you wake up: :)

Are you sure all of the P3D v3.1 .dll files are in your G:\BGLDec folder?

It looks like it is moving past the index section into the first PTC compressed section. What / how many files does it output before it crashes? Is it stuck at the same place as before?

FSX Resmaple "shouldn't" be a problem to my knowledge. Just needs P3D v3.1 to decompress the thing.

If we've got some bugs maybe you can PM me a link to your BGL, Dropbox or something, and I can debug on my end. 250MB is big! But shouldn't be a problem. dem0202.bgl is part of my test suite, which is 229 MB. It takes about 15 minutes and contains about 11 GB of decompressed data!
 
#28
So far so good. Command line is case sensitive. bmp did not work - no error .

Also must supply BMP or BIN - not an option as indicated by [BIN|BMP]

C:\Users\Ron\Downloads\bgldec_0_5_1>bgldec dem0302.bgl BMP
BGLDEC v0.5.1 - A BGL DECompressor for resampled data in P3D v3.1

BGL FileName: dem0302.bgl
Mode: BMP
Output Directory: Local

* Input File Read
* BGL Header Read, 2 Sections
* Decompilation Started
* Decompiling Section 0, 34825 subsections
* Decompiling Section 1, 54 subsections
* Decompilation Finished
* BGLStats File Written

Processing Done

bgl is 105Mb.

dem.png
 
#29
Looking good Ron!

Good catch, minor bug on my end. I have fixed and will probably release an update soon once more bugs arise.

As you can see, the elevation color ramp isn't nearly as good as it is in TMFViewer, I would like to work on that in the future. However, if you output as BIN, you would get exactly what is in the sim, and can verify with a hex viewer.

Everything can be run back through resample using the following settings, with the right ULXMAP and ULYMAP, for a roundtrip. Obviously a pain with all of the files, but I'm working on a program to combine these and automate this.

Code:
Type = RAW
GCS = WGS84
BandLayout = BIP
SampleType = UINT16
nBands = 1
 
#31
I work on Windows 7 64b and so I have tried to install the VC++ 2015 (x64) in order to use bgldec ... but my vc_redist_x64.exe installation does'nt succeed !
So I try to find msvcp140.dll and vcruntime140.dll on my Windowsbut theses two dll have been find under C:\Users\"users"\Appdata\Roaming\Dropbox\bin ??? and when I tried to install them under C:\Windows ... nothing succed ?

So I tried to copy them under W:\BGLDEC directory and here ... I succed in my BGLDEC use !!!
At the end of the decompilation/resample, the program BGLDEC crash but the BMP files are created so ....

PS: I don't copy P3Dv3.1 dll under BGLDEC directory
 

arno

Administrator
Staff member
FSDevConf team
Resource contributor
#32
Didn't the author say you need the x86 redistributable instead of the x64? No matter if your OS is 64 bit, if the software is build as 32 bit you need those redistributables.
 
#33
Yes, Arno is correct. You definitely need the x86 2015 VC++ redistributable, as it is a 32 bit program.

As seen above, you MAY need the dlls from P3D v3.1. If there are any PTC encoded segments in the BGL it will fail without those. Anything that is Bitpack, Delta, LZ1, or LZ2 compressed can be handled by BGLDEC without the sim dlls.

As you can see, this situation is not ideal. But I would rather devote my limited time towards finishing my PTC implementation, which removes the dependency on the sim completely, than supporting a bunch of different versions of the sim. So for now I will only be able to keep it up to date with the latest P3D as that is what I run.

So for now consider this a "technical preview" that may be of some value to power users. It shows that the old adage that raster BGL files cannot be read is simply not true. With lossy compression you won't get your source back, but the sim still has to read the output somehow! They are not encrypted as some have said, and actually have a fairly simple structure (as far as FS binary files go). The data is just compressed with some really wicked proprietary compression schemes. Even their LZ2 implementation (which is really similar to zip) is nonstandard. PTC is even worse, because it is only used by Microsoft and there is very little information on it outside of the MS Research whitepaper. But conceptually, it is not too different from JPEG2000. Also, FS uses a nonstandard PTC implementation with different headers from other MS products, (Microsoft Document Imaging, Xbox SDK, etc. ). So I was prepared for a challenge when I took this on, but it's not easy.
 
#34
@Golf-HotelDelta, I ran your BGL through on my machine and there were no errors. It is just the 3.1 runtime that is needed for PTC. Hang tight, I'm working towards removing this dependency.

@Lagaffe, you need the x86 installer. Interesting that the installation would fail, that one is on MS. It would install to System32. Don't know why the program would crash at the end, probably related to the botched C++ runtime. Did you make it all the way to:

Code:
* Decompilation Finished
* BGLStats File Written

Processing Done
 
#36
I am still working on my PTC implementation, hopefully I can get this working soon. I am fighting some wicked bugs with it. The headers are working but the second I hit the first band the stack corrupts. Assembly language is nasty stuff, I am very thankful I do C# and node.js at my day job. :)
What is your email? Or can I PM you? Willing to help
 
Last edited:
#39
Updated to 0.5.2 to support P3D 3.2. Old version still attached for anybody running 3.1. I was hoping to have all of this straightened out before having to support another sim version, but no such luck.

I am working hard to remove the dependency on the sim dlls for PTC. Despite my lack of posts, I have made some major progress recently, it is now decoding all bytes in my input properly but just not dequantizing the output. Really hope to get this straightened out soon so I can get back to adding features to get this to more of a user-friendly solution that everybody can use.
 
Top