In an encoding apparatus or method, variable-length encoding data is packetized
by a packetizing format in which a header of a packet has an area for indicating
a packet length and the range of values indicating the packet length is limited.
Variable-length encoding data is input and the data length of the variable-length
encoding data is detected. According to the detection result, the input variable-length
encoding data is packetized within the packet-length maximum value which can be
specified in the header.