This invention re-encodes encoded data (e.g., PackBits encoded data), which
is expressed by a data format of a runlength code part indicating the runlength
of the same data and a data part indicating the data, and a runlength code part
indicating the runlength of a different data stream and a data part indicating
the different data stream, to the same data format without decoding that encoded
data, thereby improving a compression ratio. To this end, upon reception of data
encoded by a PackBits encoding process, a data division unit separates that data
into information indicating the runlength of data, and a data part, and outputs
them as num and data. A data processing unit masks a predetermined bit in accordance
with an instruction from a monitor unit, and outputs that result to a data combining
unit. The data combining unit and a data output unit reconstruct and output data
in the PackBits format in accordance with the masked data part and num data.