Patent ID: 7715639

Claim:
A data encoding apparatus comprising: a prediction error value calculator adapted to calculate a prediction error value through adaptive prediction of data; a corrected prediction error value calculator adapted to perform predetermined filtering on a prediction error value relating to target data and a prediction error value determined in the past, in order to calculate a corrected prediction error value in which the prediction error value relating to the target data is corrected; an encoder adapted to encode the corrected prediction error value by dividing the corrected prediction error value into a variable length code part and a fixed length code part; a run counter adapted to determine a number of corrected prediction error values, without break, equal to or lower than a predetermined threshold; and code length setting portion adapted to set a code length of the fixed length code part of the corrected prediction error value in accordance with the number detected by the run counter, wherein a plurality of threshold types may be set as the threshold, wherein, in relation to each of the plurality of set threshold types, the run counter detects the number of corrected prediction error values, without break, equal to or lower than the threshold, and wherein when the number detected by the run counter in relation to a first threshold is equal to or higher than a predetermined run length, the code length setting portion sets a first code length to be shorter than a second code length obtained when the number detected by the run counter in relation to a second threshold, which is greater than the first threshold, is equal to or higher than the predetermined run length.