A method of decoding a bitstream, the method comprising: receiving an encoded bitstream; extracting transformation coefficients from the received bitstream as a 2-dimensional, 2D, matrix by performing an inverse-scanning on coefficients included in the bitstream;; dividing the 2D matrix into a plurality of sub-blocks using information included in the bitstream; outputting values of the transformation coefficients and position information of the values while performing the inverse-scanning; determining a SubBlockPosX and a SubBlockPosY, which are variables indicating a maximum position in an X-axis of a sub-block including at least one nonzero transformation coefficient and a maximum position in a Y-axis of the sub-block, respectively; determining a value of a MaxPosX, which is a variable indicating a maximum X-position in the 2D-matrix of the sub-block with maximum position in an X-axis including at least one transformation coefficient, based on the SubBlockPosX; determining a value of a MaxPosY, which is a variable indicating a maximum Y-position in the 2D-matrix of the sub-block with maximum position in a Y-axis including at least one transformation coefficient, based on the SubBlockPosY; performing an inverse-transform on one or more transformation coefficients in a partial region included in the determined value of the MaxPosX and the determined value of the MaxPosY; and generating a current frame by using a previous frame and a residual composed of inverse-transformed coefficients, wherein the determining of the SubBlockPosX and the SubBlockPosY comprises updating at least one of the SubBlockPosX and the SubBlockPosY by using the position information whenever the sub-block is input by the inverse-scanning, and wherein the updating comprises: when a sub-block includes at least one nonzero transformation coefficient, comparing a PosX of the sub-block and a current SubBlockPosX with a PosX indicating a position of the input sub-block in the X-axis; when the PosX is greater than the SubBlockPosX, updating a value of the SubBlockPosX to a value of the PosX; when a sub-block includes at least one nonzero transformation coefficient, comparing a PosY of the sub-block and a current SubBlockPosY with a PosY indicating a position of the input sub-block in the Y-axis; and when the PosY is greater than the SubBlockPosY, updating a value of the SubBlockPosY to a value of the PosY. receiving an encoded bitstream; extracting transformation coefficients from the received bitstream as a 2-dimensional, 2D, matrix by performing an inverse-scanning on coefficients included in the bitstream;; dividing the 2D matrix into a plurality of sub-blocks using information included in the bitstream; outputting values of the transformation coefficients and position information of the values while performing the inverse-scanning; determining a SubBlockPosX and a SubBlockPosY, which are variables indicating a maximum position in an X-axis of a sub-block including at least one nonzero transformation coefficient and a maximum position in a Y-axis of the sub-block, respectively; determining a value of a MaxPosX, which is a variable indicating a maximum X-position in the 2D-matrix of the sub-block with maximum position in an X-axis including at least one transformation coefficient, based on the SubBlockPosX; determining a value of a MaxPosY, which is a variable indicating a maximum Y-position in the 2D-matrix of the sub-block with maximum position in a Y-axis including at least one transformation coefficient, based on the SubBlockPosY; performing an inverse-transform on one or more transformation coefficients in a partial region included in the determined value of the MaxPosX and the determined value of the MaxPosY; and generating a current frame by using a previous frame and a residual composed of inverse-transformed coefficients, wherein the determining of the SubBlockPosX and the SubBlockPosY comprises updating at least one of the SubBlockPosX and the SubBlockPosY by using the position information whenever the sub-block is input by the inverse-scanning, and wherein the updating comprises: when a sub-block includes at least one nonzero transformation coefficient, comparing a PosX of the sub-block and a current SubBlockPosX with a PosX indicating a position of the input sub-block in the X-axis; when the PosX is greater than the SubBlockPosX, updating a value of the SubBlockPosX to a value of the PosX; when a sub-block includes at least one nonzero transformation coefficient, comparing a PosY of the sub-block and a current SubBlockPosY with a PosY indicating a position of the input sub-block in the Y-axis; and when the PosY is greater than the SubBlockPosY, updating a value of the SubBlockPosY to a value of the PosY. when a sub-block includes at least one nonzero transformation coefficient, comparing a PosX of the sub-block and a current SubBlockPosX with a PosX indicating a position of the input sub-block in the X-axis; when the PosX is greater than the SubBlockPosX, updating a value of the SubBlockPosX to a value of the PosX; when a sub-block includes at least one nonzero transformation coefficient, comparing a PosY of the sub-block and a current SubBlockPosY with a PosY indicating a position of the input sub-block in the Y-axis; and when the PosY is greater than the SubBlockPosY, updating a value of the SubBlockPosY to a value of the PosY.