uint32 CompressTouche::compress_sound_data_file(uint32 current_offset, Common::File &output, Common::File &input, uint32 *offs_table, uint32 *size_table, int len) { int i, size; uint8 buf[2048]; uint32 start_offset = current_offset; /* write 0 offsets/sizes table */ for (i = 0; i < len; ++i) { offs_table[i] = input.readUint32LE(); size_table[i] = input.readUint32LE(); output.writeUint32LE(0); output.writeUint32LE(0); current_offset += 8; } for (i = 0; i < len; ++i) { if (size_table[i] == 0) { offs_table[i] = 0; } else { input.seek(offs_table[i], SEEK_SET); input.read_throwsOnError(buf, 8); if (memcmp(buf, "Creative", 8) != 0) { error("Invalid VOC data found"); } print("VOC found (pos = %d) :", offs_table[i]); input.seek(18, SEEK_CUR); extractAndEncodeVOC(TEMP_RAW, input, _format); /* append converted data to output file */ Common::File temp(tempEncoded, "rb"); size_table[i] = 0; while ((size = temp.read_noThrow(buf, 2048)) > 0) { output.write(buf, size); size_table[i] += size; } offs_table[i] = current_offset; current_offset += size_table[i]; } } /* fix data offsets table */ output.seek(start_offset, SEEK_SET); for (i = 0; i < len; ++i) { output.writeUint32LE(offs_table[i]); output.writeUint32LE(size_table[i]); } output.seek(0, SEEK_END); return current_offset; }