Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lz4enc should not have an auto detection to check if data should be compressed or not #4

Open
bhrousseau opened this issue Feb 16, 2024 · 0 comments

Comments

@bhrousseau
Copy link

lz4enc have an auto detection to check if data should be compressed or not based on output size vs original size.
But vgmpacker and the player are only handling compressed streams.

      # did compression do harm ?
      useCompression   = len(block) < uncompressedSize and not uncompressed

I recommend to force useCompression to True.

This defect will happen when small sized VGM are encoded, in this log we can see that testUnpackLZ4 does not handle the uncompressed flag and fails.

  Selecting best matches...
 Writing output block - uncompressed (12), compressed (13) ...
  Uncompressed data selected for this block.

new token, unpacked offset=0
literal_count=15, literal_length=15
literal_count=240, literal_length=255
copy literals - literal_length=255
literal byte copy n=0, to offset 0, with byte 0xf0
literal byte copy n=1, to offset 1, with byte 0xf0
literal byte copy n=2, to offset 2, with byte 0xf0
literal byte copy n=3, to offset 3, with byte 0xf0
literal byte copy n=4, to offset 4, with byte 0xf0
literal byte copy n=5, to offset 5, with byte 0xf0
literal byte copy n=6, to offset 6, with byte 0xf0
literal byte copy n=7, to offset 7, with byte 0xf0
literal byte copy n=8, to offset 8, with byte 0xf0
literal byte copy n=9, to offset 9, with byte 0xf0
Traceback (most recent call last):
  File "C:\Users\bhrou\git\6809-game-builder\toolbox\audio\vgm2vgc\src\main\resources\vgmpacker\vgmpacker.py", line 806, in <module>
    packer.process(src, dst, args.buffer, args.huffman)
  File "C:\Users\bhrou\git\6809-game-builder\toolbox\audio\vgm2vgc\src\main\resources\vgmpacker\vgmpacker.py", line 715, in process
    self.testUnpackLZ4(compressed_block, stream)
  File "C:\Users\bhrou\git\6809-game-builder\toolbox\audio\vgm2vgc\src\main\resources\vgmpacker\vgmpacker.py", line 485, in testUnpackLZ4
    byte = getByte()
  File "C:\Users\bhrou\git\6809-game-builder\toolbox\audio\vgm2vgc\src\main\resources\vgmpacker\vgmpacker.py", line 459, in getByte
    byte = compressed[self.index]
IndexError: bytearray index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant