An encoding apparatus and method prevents image deterioration generated by repeatedly
performing encoding and decoding by using a quantization matrix for quantization
which is different from a quantization matrix for inverse quantization. In the
encoding apparatus, a matrix selector selects a first quantization matrix in accordance
with the complexity of an encoded picture pattern, and supplies a quantizer with
information on the selected first quantization matrix. A matrix unit rewrites,
by information on a second quantization matrix, the information described in an
encoded stream output from a variable length code unit so that a quantization matrix
to be used for inverse quantization is a second quantization matrix different from
the first quantization matrix.