Data encoding apparatus for context-adaptive binary arithmetic, CABAC, encoding of input data values of a data set for encoding, the data set comprising syntax elements representing a group of quantised image data coefficients, followed by bypass encoding of data representing values of the group which are not represented by the data set, the apparatus comprising: a selector configured to select one of a plurality of complementary sub-ranges of a set of code values according to the value of a current input data value, the set of code values being defined by a range variable, and to assign the current input data value to a code value within the selected sub-range, in which, for CABAC encoding of an input data value, the proportions of the sub-ranges relative to the set of code values are defined by a context variable associated with the input data value and for bypass data encoding, fixed proportions of the sub-ranges relative to the set of code values are used; a modifier configured to modify the set of code values in dependence upon the assigned code value and the size of the selected sub-range; a normaliser configured to detect whether the range variable defining the set of code values is less than a predetermined minimum size and if so, to successively increase the range variable so as to increase the size of the set of code values until it has at least the predetermined minimum size; and to output an encoded data bit to an encoded bitstream in response to each such size-increasing operation; a range variable setter configured, after CABAC encoding of the data set representing the group, to set the range variable to a value selected from a predetermined subset of available range variable values, each value in the subset having at least one least significant bit equal to zero, so as to bit-align the encoded bitstream prior to the bypass data encoding; characterised in that the apparatus further comprises: a bypass data quantity detector configured to detect the quantity of bypass data associated with a current group of quantised image data coefficients; in which the range variable setter is configured to set the range variable if the quantity of bypass data exceeds a threshold amount, but not to set the range variable otherwise. a selector configured to select one of a plurality of complementary sub-ranges of a set of code values according to the value of a current input data value, the set of code values being defined by a range variable, and to assign the current input data value to a code value within the selected sub-range, in which, for CABAC encoding of an input data value, the proportions of the sub-ranges relative to the set of code values are defined by a context variable associated with the input data value and for bypass data encoding, fixed proportions of the sub-ranges relative to the set of code values are used; a modifier configured to modify the set of code values in dependence upon the assigned code value and the size of the selected sub-range; a normaliser configured to detect whether the range variable defining the set of code values is less than a predetermined minimum size and if so, to successively increase the range variable so as to increase the size of the set of code values until it has at least the predetermined minimum size; and to output an encoded data bit to an encoded bitstream in response to each such size-increasing operation; a range variable setter configured, after CABAC encoding of the data set representing the group, to set the range variable to a value selected from a predetermined subset of available range variable values, each value in the subset having at least one least significant bit equal to zero, so as to bit-align the encoded bitstream prior to the bypass data encoding; characterised in that the apparatus further comprises: a bypass data quantity detector configured to detect the quantity of bypass data associated with a current group of quantised image data coefficients; in which the range variable setter is configured to set the range variable if the quantity of bypass data exceeds a threshold amount, but not to set the range variable otherwise. a bypass data quantity detector configured to detect the quantity of bypass data associated with a current group of quantised image data coefficients; in which the range variable setter is configured to set the range variable if the quantity of bypass data exceeds a threshold amount, but not to set the range variable otherwise.