 
             out.append(try LZ4.process(block: blockData))
         }
-        return out
-    }
-
-    private static func process(frame data: Data, _ dictionary: Data?, _ extDictId: UInt32?) throws -> Data {
+        return (out, reader.offset)
+    }
+
+    private static func process(frame data: Data, _ dictionary: Data?, _ extDictId: UInt32?) throws -> (Data, Data.Index) {
         // Valid LZ4 frame must contain frame descriptor (at least 3 bytes) and EndMark (4 bytes), assuming no data blocks.
         guard data.count >= 7
             else { throw DataError.truncated }


public enum LZ4: DecompressionAlgorithm {

    public static func decompress(data: Data) throws -> Data {
        return try LZ4.decompress(data: data, dictionary: nil)
    }

        return size + 4
    }

    // The functions below return uncompressed data and the offset to the next byte after the processed frame (even if
    // the end of the input data was reached). The offset is needed to make multiDecompress function work.

    private static func process(legacyFrame data: Data) throws -> (Data, Data.Index) {
        let reader = LittleEndianByteReader(data: data)
        var out = Data()
        // The end of a frame is determined is either by end-of-file or by encountering a valid frame magic number.
