Skip to content

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

@bhrousseau

Description

@bhrousseau

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions