A method for encoding multiple pixels of input data , the method comprising: generating a residual block of data by subtracting a reference block of data from a current block of the input data; generating a first block of coefficients by applying a transformation and a quantization to the residual block; arranging values x[i] of the first block of coefficients in a one-dimensional ordering according to a predetermined scanning pattern, whereby each coefficient value x[i] within the first block of coefficients has an associated position index i which represents a position in the one-dimensional ordering; mapping the coefficients x[i] of the first block of coefficients onto a series of binary symbols bin[i]; deriving a series of reference block prediction coefficients r[i] by applying the same transformation and quantization to the reference block that was applied to the residual block ; determining a position index i associated with each reference block prediction coefficient r[i] by using the one-dimensional ordering of the coefficients x[i] of the first block of coefficients ; and determining a losslessly decodable entropy code value representing the series of symbols bin[i] by using respective estimated probabilities p[j] wherein the estimated probability p[j] for each symbol bin[i] is determined using a context index j that is determined by: j = 4 i + min log 2 numPredSig + 1 , 3 ; or j = 4 i + min log 2 r i + 1 , 3 ; where i represents the position index associated with the corresponding reference block prediction coefficient r[i], numPredSig represents a number of non-zero reference block prediction coefficients in the series of reference block prediction coefficients r[i], and r[i] is the value of the reference block prediction coefficient at the corresponding position index i. generating a residual block of data by subtracting a reference block of data from a current block of the input data; generating a first block of coefficients by applying a transformation and a quantization to the residual block; arranging values x[i] of the first block of coefficients in a one-dimensional ordering according to a predetermined scanning pattern, whereby each coefficient value x[i] within the first block of coefficients has an associated position index i which represents a position in the one-dimensional ordering; mapping the coefficients x[i] of the first block of coefficients onto a series of binary symbols bin[i]; deriving a series of reference block prediction coefficients r[i] by applying the same transformation and quantization to the reference block that was applied to the residual block ; determining a position index i associated with each reference block prediction coefficient r[i] by using the one-dimensional ordering of the coefficients x[i] of the first block of coefficients ; and determining a losslessly decodable entropy code value representing the series of symbols bin[i] by using respective estimated probabilities p[j] wherein the estimated probability p[j] for each symbol bin[i] is determined using a context index j that is determined by: j = 4 i + min log 2 numPredSig + 1 , 3 ; or j = 4 i + min log 2 r i + 1 , 3 ; where i represents the position index associated with the corresponding reference block prediction coefficient r[i], numPredSig represents a number of non-zero reference block prediction coefficients in the series of reference block prediction coefficients r[i], and r[i] is the value of the reference block prediction coefficient at the corresponding position index i. <EOS>