pub fn transcode<R, W>(
input: &mut R,
output: &mut W,
format: Format,
sec_comp: Option<SecondaryCompression>,
output_segment_size: usize,
) -> Result<()>
Expand description
Transcodes a patch from one format to another. This function also attempts to optimize the patch operations while it is transcoding. The routine is as follows:
- It groups adjacent Add operations together, and joins adjacent Run operations.
- It then makes sure that Add operations are no larger than the maximum instruction size.
- The Run operations are also optimized to be no larger than the maximum run length.
- If a Run is long enough, it this fn will encode them using progressively larger Copy operations, until the whole run length is covered.
§Arguments
input
- The input patch to transcode.output
- The writer to write the transcoded patch to.format
- The format to transcode the patch to.sec_comp
- The secondary compression to use, if any.output_segment_size
- The size of the output segments.
§Errors
Returns an error if there was an issue reading from the input or writing to the output. Can also error if there are any invalid operations in the input patch.