A computer readable storage medium encoded with computer executable instructions, wherein the instructions, when executed by a video processing apparatus, cause the video processing apparatus to perform a method for calculating run and level representations of quantized transform coefficients representing pixel values included in a block of a video picture, the method comprising:
- packing, at the video processing apparatus, each quantized transform coefficients in a value interval [Max, Min] by setting all quantized transform coefficients greater than Max equal to Max, and all quantized transform coefficients less than Min equal to Min;
- reordering, at the video processing apparatus, the quantized transform coefficients according to a predefined order depending on respective positions in the block resulting in an array C of reordered quantized transform coefficients;
- masking, at the video processing apparatus, C by generating an array M containing ones in positions corresponding to positions of C having non-zero values, and zeros in positions corresponding to positions of C having zero values;
- generating, at the video processing apparatus, for each position containing a one in M, a run and a level representation by setting the level value equal to an occurring value in a corresponding position of C;
- and
- setting, at the video processing apparatus, for each position containing a one in M, the run value equal to the number of proceeding positions relative to a current position in M since a previous occurrence of one in M.