Jump to content


Photo

BAM Resizer

bamresize BAM

  • Please log in to reply
23 replies to this topic

#21 Argent77

Argent77
  • Staff
  • 1039 posts

Posted 05 December 2016 - 12:34 PM

Interesting.  NI and BAMWorkshop seem to open it ok, but BAMWorkshop II, WinBAM, and bamresize (obviously) don't.  DLTCEP throws the error message "Animation loaded with errors"

 

I have seen two different strategies used to load (and un-RLE) frame data from a BAM.  The first is to jump to OffsetToFrameData and start reading bytes.  If the frame data is RLEd, it is un-RLEd as bytes are being read until Width*Height number of bytes is reached.  The second is to read a block of data from OffsetToFrameData of the current frame to OffsetToFrameData of the next numerically higher frame data offset, then un-RLE the whole thing.  The error you have reported would make since if NI uses something analogous to the 1st method while bamresize uses something similar to the 2nd AND there are unused bytes between the blocks of frame data.  I haven't dusted off the bamresize source code to verify this yet, tho.

 

After poking CDMF4G12.BAM for a few minutes, the above scenario seems to fit.  In fact, my work-in-progress, internal-use-only BAM analyzer reports:

 

W: SizeOfFrameData>BytesReadFrameData (93184>83384)

I'll dig up bamresize off my external HD and take a look (and maybe put it on github while I'm at it...)  How urgently do you need a fix?

It's not urgent. I have already worked around the issue by decoding and re-encoding the affected files with NI's BAM Converter. Only the two mentioned files (out of over 1000) were making trouble.
 



#22 Sam.

Sam.
  • Modder
  • 1073 posts

Posted 07 December 2016 - 08:14 AM

Interesting.  NI and BAMWorkshop seem to open it ok, but BAMWorkshop II, WinBAM, and bamresize (obviously) don't.  DLTCEP throws the error message "Animation loaded with errors"

 

I have seen two different strategies used to load (and un-RLE) frame data from a BAM.  The first is to jump to OffsetToFrameData and start reading bytes.  If the frame data is RLEd, it is un-RLEd as bytes are being read until Width*Height number of bytes is reached.  The second is to read a block of data from OffsetToFrameData of the current frame to OffsetToFrameData of the next numerically higher frame data offset, then un-RLE the whole thing.  The error you have reported would make since if NI uses something analogous to the 1st method while bamresize uses something similar to the 2nd AND there are unused bytes between the blocks of frame data.  I haven't dusted off the bamresize source code to verify this yet, tho.

 

After poking CDMF4G12.BAM for a few minutes, the above scenario seems to fit.  In fact, my work-in-progress, internal-use-only BAM analyzer reports:

 

W: SizeOfFrameData>BytesReadFrameData (93184>83384)

I'll dig up bamresize off my external HD and take a look (and maybe put it on github while I'm at it...)  How urgently do you need a fix?

It's not urgent. I have already worked around the issue by decoding and re-encoding the affected files with NI's BAM Converter. Only the two mentioned files (out of over 1000) were making trouble.

Actually, bamresize uses a form of the first method I described, but when the last byte of RLE'd data was expanded, there ended up being more bytes of data than width*height like there should have been.  @Argent77, I think I've come up with an effective fix, but I had to recreate my old compile environment on my new computer.  If you don't mind, I would really appreciate if you could put the new version through the ringer for me to make sure nothing got screwed up:

 

Edit: Removed attachment.  See 1st post for links to latest version


Edited by Sam., 07 December 2016 - 06:22 PM.

"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

-- to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage


#23 Argent77

Argent77
  • Staff
  • 1039 posts

Posted 07 December 2016 - 11:48 AM

The new version works great so far. I have processed all 17000+ BAM (V1) files from BG2EE without errors or graphics corruption.



#24 Sam.

Sam.
  • Modder
  • 1073 posts

Posted 07 December 2016 - 06:36 PM

The new version works great so far. I have processed all 17000+ BAM (V1) files from BG2EE without errors or graphics corruption.

Awesome, thanks!
 
BAM Resizer is now available on GitHub!  I have updated the 1st post and SHS download accordingly.
 




v2.9 (06 December 2016)

  • Improved handling of corrupt RLE'd frame data.

 


"Ok, I've just about had my FILL of riddle asking, quest assigning, insult throwing, pun hurling, hostage taking, iron mongering, smart-arsed fools, freaks, and felons that continually test my will, mettle, strength, intelligence, and most of all, patience! If you've got a straight answer ANYWHERE in that bent little head of yours, I want to hear it pretty damn quick or I'm going to take a large blunt object roughly the size of Elminster AND his hat, and stuff it lengthwise into a crevice of your being so seldom seen that even the denizens of the nine hells themselves wouldn't touch it with a twenty-foot rusty halberd! Have I MADE myself perfectly CLEAR?!"

-- to Portalbendarwinden

--------------------

post-10485-0-15080600-1348188745.jpg
___________Old pen and paper modules of the 70s and 80s.___________

CA Forums CA Homepage






Also tagged with one or more of these keywords: bamresize, BAM