```mermaid sequenceDiagram participant Encoder participant File as "RLE File" participant Decoder Encoder->>File: write header (Type, Mode, ID, Size) Encoder->>File: emit literal packet (count-1 + literals) Encoder->>File: emit run packet (0x7D + N, byte or offset) Encoder->>File: emit backref packet (0x7E + len, distance-1) File->>Decoder: provide packet stream Decoder->>Decoder: if control < 0x80 → copy (control+1) literals Decoder->>Decoder: else → read param; if run → repeat byte; if backref → copy from output buffer Decoder-->>File: produce decompressed bytes (output) ``` ```mermaid sequenceDiagram participant Encoder participant File as "RLE File" participant Decoder Encoder->>File: write header (Type, Mode, ID, Size) Encoder->>File: emit literal packet (count-1 + literals) Encoder->>File: emit run packet (0x7D + N, byte or offset) Encoder->>File: emit backref packet (0x7E + len, distance-1) File->>Decoder: provide packet stream Decoder->>Decoder: if control < 0x80 → copy (control+1) literals Decoder->>Decoder: else → read param; if run → repeat byte; if backref → copy from output buffer Decoder-->>File: produce decompressed bytes (output) ```