A data encoding method for encoding an array of data values as data sets and escape codes for values not encoded by the data sets, an escape code comprising a unary coded portion and a non-unary coded portion, the method comprising the steps of: generating (2030, 2040, 2050) one or more data sets indicative of positions, relative to the array of data values, of data values of predetermined magnitude ranges, so as to encode the value of at least one least significant bit of each data value; generating escape codes from at least the part of each data value not encoded by the one or more data sets, wherein the step of generating escape codes comprises: generating respective complementary most-significant data portions and least-significant data portions, such that the most-significant data portion of a value represents zero or more most significant bits of that portion and the respective least-significant data portion is dependent upon a number of least significant bits of that part, the number of least significant bits being greater than or equal to a minimum least significant data portion size obtained by setting a coding parameter defining a minimum number of bits of the non-unary coded portion, the coding parameter being between 0 and a predetermined upper limit, and adding an offset value of 1 or more to the coding parameter so as to define the minimum least significant data portion size; encoding the data sets to an output data stream; encoding the most significant data portions to the output data stream; and encoding the least-significant portions to the output data stream. generating (2030, 2040, 2050) one or more data sets indicative of positions, relative to the array of data values, of data values of predetermined magnitude ranges, so as to encode the value of at least one least significant bit of each data value; generating escape codes from at least the part of each data value not encoded by the one or more data sets, wherein the step of generating escape codes comprises: generating respective complementary most-significant data portions and least-significant data portions, such that the most-significant data portion of a value represents zero or more most significant bits of that portion and the respective least-significant data portion is dependent upon a number of least significant bits of that part, the number of least significant bits being greater than or equal to a minimum least significant data portion size obtained by setting a coding parameter defining a minimum number of bits of the non-unary coded portion, the coding parameter being between 0 and a predetermined upper limit, and adding an offset value of 1 or more to the coding parameter so as to define the minimum least significant data portion size; encoding the data sets to an output data stream; encoding the most significant data portions to the output data stream; and encoding the least-significant portions to the output data stream. generating respective complementary most-significant data portions and least-significant data portions, such that the most-significant data portion of a value represents zero or more most significant bits of that portion and the respective least-significant data portion is dependent upon a number of least significant bits of that part, the number of least significant bits being greater than or equal to a minimum least significant data portion size obtained by setting a coding parameter defining a minimum number of bits of the non-unary coded portion, the coding parameter being between 0 and a predetermined upper limit, and adding an offset value of 1 or more to the coding parameter so as to define the minimum least significant data portion size; encoding the data sets to an output data stream; encoding the most significant data portions to the output data stream; and encoding the least-significant portions to the output data stream.