For traditional algorithms compressed data may vary, while decompression algorithm is always the same. Are there any approaches, when (de)compression algorithm is also changing to provide best compression level? One can think about splitting data as small chunks and for each small chunk iterate all possible (de)compression codes to get best compression. Is there any research or existing algorithms, utilizing ideas like that?
Suppose the first byte of the compressed file indicates which decompression algorithm to use, and then you use that algorithm to decompress the rest. Sure, you could do that. Absolutely. Some compression formats already do exactly this.
That said, it's also possible to view this as a single decompression algorithm. The master algorithm looks at the first byte of the file and then branches to a subroutine that handles the rest of the file. That can be considered a single algorithm. So at a fundamental level there is no fundamental distinction that can be drawn.
DEFLATE the stock standard compression algorithm will do exactly that. There are 3 type of blocks differentiated by a 2 bit value at the start of each block:
- the raw bytes for when the other two won't make it any smaller
- compressed with a fixed huffman encoding when the custom tree would take too much space for what it would save
- compressed with a supplied huffman encoding
The size of each block is free to choose the compressor as it sees fit.