Method and apparatus for encoding video signal and method and apparatus for decoding video signal
Provided are a method and apparatus for encoding a video signal and a method and apparatus for decoding a video signal. The method of encoding the video signal includes: determining an optimum scaling bit depth of the video signal in consideration of a maximum bit number of an intermediate value obtained during transformation of the video signal and a maximum bit precision of the video signal; scaling the video signal according to a local shift value corresponding to a difference between the determined optimum scaling bit depth and an original bit depth of the video signal; and transforming the scaled video signal.
1. A method of decoding a video, the method comprising:
determining bit depth of samples in a video sequence;
obtaining quantized transform coefficients of a transform block in the video sequence from a bitstream;
generating scaled transform coefficients of the transform block by performing inverse-quantization and scaling on the quantized transform coefficients;
generating intermediate sample values of the transform block by performing vertical inverse-transformation on the scaled transform coefficients; and
generating residual values of the transform block by performing horizontal inverse-transformation on the intermediate sample values of the transform block;
generating a prediction block by performing intra prediction or inter prediction; and,
restoring sample values using the residual values of the transform block and the prediction block,
wherein the scaling on the quantized transform coefficients comprises:
determining an offset value based on a scaling variable, adding the inverse-quantized transform coefficients to the offset value and bit shifting on the added transform coefficients by the scaling variable, and
wherein the scaling variable is generated by using a size of the transform block and the bit depth of samples.
2. The method of claim 1 , wherein each of the vertical inverse-transformation and horizontal inverse-transformation includes linear transformation that is a discrete cosine transform (DCT) operation or a discrete wavelet transform (DWT) operation.