A video codec comprising: a processor configured to: generate a prediction block for a current block; compute a difference between the current block and the prediction block to generate a residual block; scan a plurality of prediction residuals located in the residual block without conversing the prediction residuals of the residual block in a spatial domain to transform coefficients of a transform matrix in a frequency domain; and if the plurality of residual values comprise at least one non-zero prediction residual, entropy encode the at least one non-zero prediction residual; wherein the prediction block is generated based on an intra prediction mode, wherein scanning the plurality of prediction residuals follows a scanning order, and wherein the scanning order is determined based on the intra prediction mode and a size of the prediction block; wherein the processor is further configured to: if the size of the prediction block is no greater than a pre-configured limit and the intra prediction mode belongs to a horizontal group, set the scanning order such that the plurality of prediction residuals are scanned row-by-row; otherwise if the size of the prediction block is no greater than the pre-configured limit and the intra prediction mode belongs to a vertical group, set the scanning order such that the plurality of prediction residuals are scanned column-by-column; otherwise set the scanning order to be a zigzag order; wherein if the intra prediction direction has an angle smaller than a pre-determined threshold with the horizontal axis, the intra prediction direction is classified as in the horizontal group; if an intra prediction direction has an angle smaller than a pre-determined threshold with the vertical axis, the intra prediction direction is classified as in the vertical group. a processor configured to: generate a prediction block for a current block; compute a difference between the current block and the prediction block to generate a residual block; scan a plurality of prediction residuals located in the residual block without conversing the prediction residuals of the residual block in a spatial domain to transform coefficients of a transform matrix in a frequency domain; and if the plurality of residual values comprise at least one non-zero prediction residual, entropy encode the at least one non-zero prediction residual; generate a prediction block for a current block; compute a difference between the current block and the prediction block to generate a residual block; scan a plurality of prediction residuals located in the residual block without conversing the prediction residuals of the residual block in a spatial domain to transform coefficients of a transform matrix in a frequency domain; and if the plurality of residual values comprise at least one non-zero prediction residual, entropy encode the at least one non-zero prediction residual; wherein the prediction block is generated based on an intra prediction mode, wherein scanning the plurality of prediction residuals follows a scanning order, and wherein the scanning order is determined based on the intra prediction mode and a size of the prediction block; wherein the processor is further configured to: if the size of the prediction block is no greater than a pre-configured limit and the intra prediction mode belongs to a horizontal group, set the scanning order such that the plurality of prediction residuals are scanned row-by-row; otherwise if the size of the prediction block is no greater than the pre-configured limit and the intra prediction mode belongs to a vertical group, set the scanning order such that the plurality of prediction residuals are scanned column-by-column; otherwise set the scanning order to be a zigzag order; if the size of the prediction block is no greater than a pre-configured limit and the intra prediction mode belongs to a horizontal group, set the scanning order such that the plurality of prediction residuals are scanned row-by-row; otherwise if the size of the prediction block is no greater than the pre-configured limit and the intra prediction mode belongs to a vertical group, set the scanning order such that the plurality of prediction residuals are scanned column-by-column; otherwise set the scanning order to be a zigzag order; wherein if the intra prediction direction has an angle smaller than a pre-determined threshold with the horizontal axis, the intra prediction direction is classified as in the horizontal group; if an intra prediction direction has an angle smaller than a pre-determined threshold with the vertical axis, the intra prediction direction is classified as in the vertical group.