Jump to content


Photo

BAM Resizer

bamresize BAM

  • Please log in to reply
28 replies to this topic

#21 Argent77

Argent77
  • Administrator
  • 1434 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.
  • Administrator
  • 1338 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?!"

--<CHARNAME> 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
  • Administrator
  • 1434 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.
  • Administrator
  • 1338 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?!"

--<CHARNAME> to Portalbendarwinden

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

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

CA Forums CA Homepage


#25 Salk

Salk
  • Modder
  • 1419 posts

Donator

Posted 06 May 2021 - 07:39 AM

I'm sure I am doing something wrong but each time I run the .exe, I get an error message even if everything went fine.

 

The message is:

 

File "<string>", line 1

sys.path.append('directory for BAMresize')

 

SyntaxError: invalid syntax

Processing 'nameoffile' ...

Elapsed time: 0.0 seconds



#26 Sam.

Sam.
  • Administrator
  • 1338 posts

Posted 06 May 2021 - 08:55 AM

I'm sure I am doing something wrong but each time I run the .exe, I get an error message even if everything went fine.

 

The message is:

 

File "<string>", line 1

sys.path.append('directory for BAMresize')

 

SyntaxError: invalid syntax

Processing 'nameoffile' ...

Elapsed time: 0.0 seconds


I've never seen that before.  What syntax, exactly, are you using to run it?  Does it still give this message if you run it as an administrator?


"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?!"

--<CHARNAME> to Portalbendarwinden

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

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

CA Forums CA Homepage


#27 Salk

Salk
  • Modder
  • 1419 posts

Donator

Posted 06 May 2021 - 08:21 PM

It literally shows that message no matter what I type.

 

I have attached a screenshot of my command prompt (W10) run as Administrator.

 

Attached Images

  • BAMResize.jpg


#28 Sam.

Sam.
  • Administrator
  • 1338 posts

Posted 07 May 2021 - 08:17 AM

It literally shows that message no matter what I type.

 

I have attached a screenshot of my command prompt (W10) run as Administrator.

It seems python doesn't like the apostrophe in "Baldur's Gate 2" in your filepath.  Remove that and you won't get the syntax error.


"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?!"

--<CHARNAME> to Portalbendarwinden

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

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

CA Forums CA Homepage


#29 Salk

Salk
  • Modder
  • 1419 posts

Donator

Posted 07 May 2021 - 10:11 AM

Oh that was it.

 

Curious how it did work anyway though...

 

Thanks, Sam.  :cheers:


Edited by Salk, 07 May 2021 - 10:12 AM.






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